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

15,115

Solution 1

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.

Solution 2

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.

Share:
15,115
Nick
Author by

Nick

Updated on June 07, 2022

Comments

  • Nick
    Nick about 2 years

    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