Winsock Header Weirdness
There are two main Winsock headers used depending on which version your application needs. There is winsock.h for Winsock v1.x and winsock2.h for Winsock v2.x and they are mutually exclusive. That is, if you include both header files you will see a lot of compilation errors.
As you may know, windows.h includes a lot of other header files if you don't define WIN32_LEAN_AND_MEAN in your source code. One of the headers it does include without this define is winsock.h. This can cause problems if you are intending to use Winsock 2 features and are linking to ws2_32.lib. In addition to causing obvious compilation errors (due to structure redefinitions or missing definitions) there is a subtle issue regarding IP multicast support. Winsock 1 defined the IP multicast socket options IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP as 5 and 6; however, when Winsock 2 was defined these values changed to 12 and 13. By including winsock.h and linking to wsock32.lib, these values are fixed up since the Windows operating system will only recognize the Winsock 2 values. By mismatching the header file and link library, the application would see failures when calling setsockopt.
Winsock developers should define WIN32_LEAN_AND_MEAN and explicitly include the Winsock header for the version they require as well as link with the appropriate lib -- winsock.h goes with wsock32.lib while winsock2.h goes with ws2_32.lib.