Sockets Learning Example

  • Language and platform: C on Unix Purpose:
  • Demo + source showing you how to program some simple socket connections. While the programs are specific to Unix, they illustrate how all socket programs usually work. 
  • Author: Saul Greenberg 
 

To compile and use the demos:

 
  1. Copy these files into your own directory and compile it by typing make 
  2. To run the server1 demo: 
    • Open two windows In the first window, type server1. 
    • In the second window, type client  
    • Anything you type into the client window will be sent and printed in the server window. 
  3. To run the server2 demo: 
    • As above, but run server2 instead of server1 
    • As before, anything you type into the client window will be sent and printed in the server2 window. 
    • However, the server2 program will also look at the keyboard and echo back any text typed in the server2 window. 
  4. To run the server3 demo: 
    • As above, but run server3 instead of server1 
    • You can now run several clients at the same time, connecting and disconnecting them dynamically.

Where to go from here: 

  If you want to play with sockets, try to make the client and server talk to each other using two-way communications. Note: sockets are already two-way!
 

License Terms