Winsock 1 
The Winsock 1 Tutorial consists of four small projects.  These are:  a UDP Client, a UDP Server, a TCP Client and a TCP Server.  These four programs demonstrate the bare minimum for communicating with sockets.  For those who like to jump in immediately, this is the place to start.  Each project is implemented as a dialog based MFC application and is described fully on its corresponding page. 


   
TCP Client Page                                                        UDP Client Page


   
TCP Server Page                                                    UDP Server Page


Downloads 
Programs Only  All four Winsock 1 EXE's.  No source files. 
Programs and Source Files  All four Winsock 1 EXE's, source files and project files. 
Note:  You must unzip these files with subdirectories!  (example:  "pkunzip -d ws1_full.zip") 


Discussion 
The Winsock 1 applications act in pairs.  The UDP Server listens for a messages from the UDP Cient.  Likewise, the TCP Server listens for messages from the TCP Client.  The Server must be listening on the same port that the Client is sending on.  The Server must be listening before the Client starts to send, otherwise it will not get the message.  In a UDP conversation, there will be no acknowledgement that the message was not received.  In a TCP conversation, the connect() function will fail if the server is not listening. 

To use these programs, start up a Server/Client pair of either type.  You can run them on the same machine if you like.  Then enter the TCP/IP address of the machine that is running the Server in the Client's "Server IP Address:" field.  The Server's IP address is shown in the top right field of the Server application.  Then put the Server in listen mode by pressing the "Listen" button.  Once in listen mode, the Server application will be blocking, and will not accept any input from the user until it receives a message from a Client.  The only way to stop a Server from listening without getting a message from a Client is to end the task by pressing "ctrl-alt-del." 

Once the Server is listening and the Server's IP address is in the Client's "Server IP Address:" field, you can type in your message and hit the "Send" button.  Make sure that the Server and Client are using the same port number or the message will not be received. 

That is all there is to these Winsock1 tutorials.  These applications demonstrate the essentials of basic sockets communication. 


Back to Winsock Tutorials Main Page