All processes (applications or DLLs) that call Winsock functions must initialize the use of the Windows Sockets DLL before making other Winsock functions calls. This also makes certain that Winsock is supported on the system.
To initialize Winsock
- Create a WSADATA object called wsaData.
- Call WSAStartup and return its value as an integer and check for errors.
The WSAStartup function is called to initiate use of WS2_32.dll.
The WSADATA structure contains information about the Windows Sockets implementation. The MAKEWORD(2,2) parameter of WSAStartup makes a request for version 2.2 of Winsock on the system, and sets the passed version as the highest version of Windows Sockets support that the caller can use.
Next Step for a Client: Creating a Socket for the Client
Next Step for a Server: Creating a Socket for the Server