Skip to content

Sahil-Hossain-1429/TCPServerWithCpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCPServerWithCpp

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.

Introduction

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.


How to Run

Platform Requirements

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.


Compilation

Open a terminal in the project directory and compile the source file using the following command:

g++ server.cpp -o server

This command Compiles server.cpp and produces an executable named server

Execution

Run server using :

./server

Once started, the server will begin listening for incoming connections on port 8080

Connecting From another Terminal(Same Device)

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.

Connecting from a mobile Device(Within same network)

To connect from a mobile device, both the computer and the mobile device must be on the same network

  1. Retrive the ip address of the computer running the server:
hostname -I

This command will display the local IP address of the host machine.

  1. Install a terminal emulator on your mobile device.
    A recommended option is Termux.

  2. 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

Project Demonstration

Demo Screenshot

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages