This project implements a simple TCP socket server in C. The server listens for client connections, receives messages from the client, and responds with a confirmation message. It demonstrates basic socket programming concepts such as creating a socket, binding, listening, accepting connections, reading, and writing data.
- Listens for incoming client connections.
- Reads data sent by the client.
- Sends a confirmation message back to the client.
- Uses a
Makefilefor easy compilation. - Error handling for failed operations.
- GCC Compiler: Required to compile the C source files.
- POSIX-compliant system: Works on Linux/macOS.
- Basic knowledge of networking: Helps in understanding socket programming.
Clone the repository:
git clone https://github.com/mady20/cserver.git
cd cserverCompile the project using:
makeThis will generate two executable files:
server: The server application.client: The client application.
To remove compiled binaries:
make cleanRun the server with a specified port number:
./server <port_number>Example:
./server 8080Once the server is running, start the client (assuming client.c is implemented):
./client <server_ip> <port_number>Example:
./client 127.0.0.1 8080- The server binds to a specified port and listens for incoming connections.
- When a client connects, the server accepts the connection.
- The server continuously reads data sent by the client.
- The received data is printed on the server's console.
- The server responds with a confirmation message.
- The connection continues until terminated.
- Ensure the specified port is not blocked by a firewall.
- Modify
client.caccordingly to communicate with the server. - The server currently runs in an infinite loop; you may need to terminate it manually using
Ctrl + C.
This project is licensed under the MIT License.