Winsock2.h vs winsock2.h and wsock32.lib vs ws2_32.lib

Nick picture Nick · Jul 22, 2013 · Viewed 13.4k times · Source

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

Answer

David Schwartz picture David Schwartz · Jul 22, 2013

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.