Skip to content

lavochkaa/tcp-cpp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCP Server (C++)

Simple TCP / HTTP messenger server written in C++ using low-level Linux sockets.

Screenshot

🚀 Features

• Two servers in one program.

• HTTP server on port 8080.

• Chat server on port 8081.

• Login only by username.

• Chat commands: /help /ip /hello /echo /html /chat <username> /back /sent_messages /session_messages /exit

• HTTP login page.

• HTTP menu page after successful login.

• HTTP chats page.

• HTTP personal dialog page: /chat/username

• HTTP routes: / /menu /hello /about /chat /logout

• Web messages update without full page reload.

• User cannot login twice at the same time.

• 404 page for unknown routes.

⚙️ Requirements

• Docker (recommended).

• Or: Linux, g++, make.

💡 Build and Run

Docker (recommended)

Build:

docker build -t chat-server .

Run:

docker run -p 8080:8080 -p 8081:8081 chat-server

Manual (Linux only)

cd src && make && ../server

🏗️ Architecture

  • Chat server uses epoll event loop — single thread monitors all connections, new clients are dispatched to a ThreadPool.
  • HTTP server uses a simple accept loop with ThreadPool.

📁 Structure

src/
├── chat/
├── http/
├── shared/
├── storage/
└── web/
    ├── pages/
    └── assets/

🌐 HTTP

Open in browser:

http://127.0.0.1:8080/

Main pages:

/
/menu
/chat
/chat/username

💬 Chat

Connect from terminal:

nc 127.0.0.1 8081

Then enter only your username.

About

TCP server with HTTP (port 8080) and real-time chat (port 8081) built from scratch in C++ using POSIX sockets — web UI, auth, chat commands, dynamic message updates. No frameworks.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages