The following is the complete source code for the basic Winsock TCP/IP Client Application.
msdn.microsoft.com