Systems lab
TCP chat in C
A small client-server chat program built with POSIX sockets and select-based input handling.

What I built
This project is a two-way terminal chat program written in C while studying computer networks at Monash.
The server creates a TCP socket, binds to port 5100, listens for a connection, and accepts one client at a time. The client connects to the server address and both sides can send messages from standard input.
Handling two inputs
The server needs to react to either the connected client or the person typing in its terminal. I used select() with a file descriptor set so one loop could wait on both sources without blocking permanently on either one.
When the client socket is ready, the server reads and prints the message. When standard input is ready, it sends the typed buffer back through the socket.
Closing the connection
Both programs recognise an exit command. If the client exits, the server closes that client socket and goes back to waiting for another connection. If the server exits, it closes both sockets and terminates.
Limits and next steps
The lab deliberately handles one client at a time. It also uses a fixed buffer and simple text framing, so it does not solve partial messages or a client sending more than one logical message in a read.
A stronger version would support multiple clients, define a message protocol, handle partial reads and writes, and add graceful shutdown for interrupted connections.