A simple multithreaded TCP server and client written in C. The server listens on port 9999 and handles each client connection in a separate pthread.
Run the server first. It will accept incoming client connections, each handled in its own thread. To shut down the server, press Ctrl+C. It will stop accepting new connections and close the server socket.
Run the client to connect to the server and exchange messages. Type any message and press Enter to send it. The server will echo it back. As a special case, sending hello will receive world in response. To disconnect, type disconnect and press Enter. The server will reply with a goodbye message and close the connection.
mkdir build && cd build
cmake ..
make
Run the server:
./server
Run the client in a separate terminal:
./client
This project is released under the MIT License.