I am confused about couple of things about winsock.
First, what the difference between including Winsock2.h vs winsock2.h (caps of 'w')
Second, what is the difference between linking with wsock32.lib with ws2_32.lib?
I have tried couple of combinations and they result in compile time errors. Can anyone explain me the logical reasoning behind what to use?
Thanks
Nick
There is no difference between Winsock2.h
and winsock2.h
. Filenames are case-insensitive on typical Windows filesystems. The ws2_32.lib
file is for Winsock 2, while wsock32.lib
is for the obsolete, older version.
As shown here: https://technet.microsoft.com/en-us/library/cc958787.aspx, wsock32.dll and wsock.dll are the backwards-compatiblity shells for w2_32.dll
You can use wsock32.dll for compatibility with Win95, or wsock.dll for compatibility with win3.11 :) But normally they are used by Win95 and Win3.11 programs for compatibility with win2K+
wsock32.lib and w2_32.lib contain a list of the exported functions and data elements from the dynamic link libraries.
Note: some of the differences between wsock32 and ws_32 may be unexpected. For example wsock32 will run winsock version 2.2 API -- but to get version 2.0 you need w2_32.