Berkeley Sockets vs. Windows Sockets
Programs that use standard Berkeley Sockets calls will port to Windows Sockets, with the following important exceptions.
- You must call WSAStartup to initialize the Winsock DLL.
- You must use closesocket (which is not portable), rather than close (which is), to close a socket.
- You must call WSACleanup to shut down the DLL.
Optionally, you can use the Windows data types such as SOCKET and LONG in place of int, as was done in this chapter. Program 12-1 and 12-2 were ported from UNIX, and the effort was minimal. It was necessary, however, to modify the DLL and process management sections. Exercise 1213 suggests that you port these two programs back to UNIX.