This is an example application using Berkeley sockets. It illustrates use of the primitives: socket, bind. listen, accept, send, recieve, and close. See page 487 of the Tanenbaum book for more information.

Save the file webserv.c in your home directory. This is the C source code for a very simple web server.

To compile this program, type
 gcc -o webserv webserv.c
at the command prompt. To run the program, type
 ./webserv
at the command prompt.

It will listen on port 3421 on the local system, and can be accessed through a web browser. It will display a page which gives the IP address of the web client.