Lesson 11advancedIPC

TCP Sockets

Network programming with TCP sockets. Covers the full socket lifecycle (socket, bind, listen, accept, read/write, close), multiplexing with select(), and three complete client-server applications: echo, chat, and an arithmetic evaluator.

socketTCPbindlistenacceptselectclient-server
1

Echo Server

A TCP echo server using select() for multiplexing — handles multiple clients and echoes back everything received.

01-example/echo-server.c
$ gcc -o echo_server 01-example/echo-server.c
$ ./echo_server
Talks to echo-client.c — use Run pair
2

Echo Client

A TCP client that connects to the echo server and sends/receives messages.

01-example/echo-client.c
$ gcc -o echo_client 01-example/echo-client.c
$ ./echo_client 127.0.0.1
Runs together with echo-server.c — use Run pair there
3

Chat Server

A multi-client chat server — messages from one client are broadcast to all connected clients.

02-chat/chat-server.c
$ gcc -o chat_server 02-chat/chat-server.c
$ ./chat_server
Talks to chat-client.c — use Run pair
4

Chat Client

A chat client that connects to the chat server for real-time group messaging.

02-chat/chat-client.c
$ gcc -o chat_client 02-chat/chat-client.c
$ ./chat_client 127.0.0.1
Asks for input — sample input is one click awayRuns together with chat-server.c — use Run pair there
5

Arithmetic Server

A TCP server that receives arithmetic expressions, evaluates them, and returns results — a practical client-server application.

03-arithmetic/server.c
$ gcc -o arith_server 03-arithmetic/server.c
$ ./arith_server
Talks to client.c — use Run pair
6

Arithmetic Client

Sends arithmetic expressions to the server and displays the computed results.

03-arithmetic/client.c
$ gcc -o arith_client 03-arithmetic/client.c
$ ./arith_client 127.0.0.1
Asks for input — sample input is one click awayRuns together with server.c — use Run pair there

Open Full Terminal

Get a Linux terminal with all 6 files from this lesson pre-loaded. Compile, run, and experiment freely.