This project implements a TCP server in C++ using low-level socket APIs. The server establishes socket connections and allows clients on the same network to send and receive text-based data reliably and efficiently.
This project implements a basic TCP (Transmission Control Protocol) server that enables text-based communication between devices connected to the same local network. The server listens for incoming client connections and displays received messages in real time on the host machine’s terminal.
The application is entirely terminal-based and is intended for educational purposes, demonstrating fundamental concepts of socket programming, client-server communication, and network data transmission.
This project supports POSIX-compliant operating systems such as Linux and macOS.
It is not compatible with Windows due to its reliance on POSIX socket APIs.
To build and run the project, ensure that the GNU C++ compiler (g++) is installed on your system.
Open a terminal in the project directory and compile the source file using the following command:
g++ server.cpp -o serverThis command Compiles server.cpp and produces an executable named server
Run server using :
./server
Once started, the server will begin listening for incoming connections on port 8080
Open a second terminal window and connect to the server using
telnet localhost 8080
If the connection is successful, a message will appear in the client terminal:
Hello From Server
You can now type messages in the client terminal (the second terminal). Any text you enter will be transmitted to the server and displayed in the first terminal window.
To connect from a mobile device, both the computer and the mobile device must be on the same network
- Retrive the ip address of the computer running the server:
hostname -I
This command will display the local IP address of the host machine.
-
Install a terminal emulator on your mobile device.
A recommended option is Termux. -
After installing Termux, connect to the server using:
telnet your_ip_address 8080
(Replace your_ip_address with the IP address )
Once connected, the mobile device will function as a client. Any message sent from the mobile terminal will be received and displayed on the server terminal, enabling bidirectional communication between the devices.as
