Is there a requirement for using WS2_32.dll instead of wsock32.dll when building with MSVC9.0
I'm in the middle of porting some code to be compiled with MSVC 9.0, and one of my coworkers mentioned that we would need to开发者_JAVA技巧 link against WS2_32.dll because now only Winsock 2 was supported. Is there any truth to this? Our code is pretty old and heavily dependent on wsock32.dll, so this requirement could be a huge obstacle for the project.
Thanks
As long as you're not using any Winsock 2 specific features, you should be just fine linking against wsock32.dll. The old Winsock 1.1 API is not deprecated. Winsock 2 is an extension to Winsock 1, not a replacement for it.
Because Winsock 2 is purely an extension, a program that currently works against wsock32.dll should still work fine when relinked against ws2_32.dll. The best reason not to do that is if you still have to support stock Windows 95 systems, since Winsock 2 is a downloadable add-on for those systems. Winsock 2 was introduced with Windows 98 and Windows NT 4.
There are degrees to Winsock 2 support. A program using all the newest features available under Windows 7 may not work with Windows 95 even with the Winsock 2 add-on. Sometimes the reverse is true, too: the newer Winsock stacks have removed some raw sockets support available in Windows 2000 and XP, for instance.
Bottom line, test on all platforms you have to support.
精彩评论