| WinSock Tutorial
home: http://www.geocities.com/SiliconValley/Code/1219/ e-mail: craterz@hotmail.com Note: As far as programming docs go, consider this an extreme early pre-alpha version. Just sorta slapped together info from a coding sample from FAQSYS, what pathetic info given in the Visual C++ help files, and a deep curiosity and intuition. Use at your own peril. :-) Header File and Import Library You require that you include the header file winsock2.h and link the file ws2_32.lib to the final executable.
WinSock: Initializing The first step is to call WSAStartup to startup the interface to WinSock.
Server: Create Socket
Server: Starting Server
Server: Listen for Client
Server: Accepting Connection
Client: Create Socket
Client: Get Host Now we can get to the real fun. On the client side, we are going to need to find our host based on their name. For example we may be trying to connect to the server async5-5.remote.ualberta.ca. We do this using the function gethostbyname.
Client: Connecting to Server
Send and Recieve Data With a working socket connection we can now send data using the function send and receive data using the function recv. Closing Socket When we are finished with a socket, we can close it simply by calling the function closesocket. What could be easier?
WinSock: Shutdown Once finsished with the WinSock system, we need to shut it down by calling the function WSACleanup.
[ powered by Latte and Python | last updated Sat Aug 25 00:55:04 2001 PST ] |