Linux network programming. What can I start with?

c, c++, linux, network-programming

Solution

I'm not sure how in-depth you want to start your Linux Network Programming career, but if you want to just get started with dealing with sockets, probably the easiest examples are a Producer/Consumer pairing or an Echo Server. Another good source would be looking at some of the examples/assignments from any number of University/College courses on Distributed computing.

Producer/Consumer

This could be run in a pair of terminals on your computer to test. Create two applications:

- Producer program starts with a hostname and port, takes a line of input from the user, connects to the Consumer, sends it the input, asks for another line of input, and finishes when it reaches EOF (Ctrl-D).

- Consumer program starts with a listening port, waits for a connection from the Producer, reads the message sent by the Producer, outputs that message, closes the connection with the Producer, exits gracefully when sent an interrupt (Ctrl-C).

Echo Server

Similar idea to Producer/Consumer.

- Echo Server starts with a listening port, waits for a connection, reads a message from the Client, sends that same message back to the Client, and exits gracefully when sent an interrupt (Ctrl-C).

- Echo Client starts with a hostname and port, takes a line of input from the user, connects to the Server, sends the input, reads back the response, compares the two to verify it was an echo, asks for another line of input, and finishes when it reaches EOF.

Problem

I've recently got interested in Linux network programming and read quite a bit (Beej's Guide to Network Programming). But now I'm confused. I would like to write something to have some practice, but I don't know what exactly. Could please recommend me a couple of projects to start with? Thanks.

Original source