From: http://www.cic.tsinghua.edu.cn/jdx/book1/CHAPTER3.htm
Add the # include <winsock. h> statement to the source file.
Call the WSAStartup () function to initialize Windows Sockets DLL, and call the WSACleanup () function at the end to notify Windows Sockets DLL to release resources.
Change the SOCKET type to int type to SOCKET.
Do not use the global variable errno to obtain and set error codes. Change the value to the WSAGetLastError () function and WSASetLastError () function recommended by Windows Sockets.
Use the closesocket () function instead of the close () function to close the socket. Use the ioctlsocket () function instead of the ioctl () function and the fcntl () function to control the socket mode.
The getsockopt () function and setsockopt () function provide different support in Berkeley Sockets and Windows Sockets. The source program may need to be modified. For details, see Chapter 6 function usage instructions.
Change the structure fd_set in the source program to be modified by using the FD_XXX macro.
Change the error code in the source program to the constant value defined by WSA header recommended by Windows Sockets.
Set the pointer of the Windows Sockets application to the FAR type.
It is best to change the blocking call in the source program to the message-based Asynchronous Operation recommended by Windows Sockets.