Skip to content

Latest commit

 

History

53 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

New Server

A low-level network server written in C with a Python client interface used to interact with the server through command-line commands. This project focuses on implementing core systems programming concepts such as socket communication, event-driven I/O, thread pools, and custom data structures.

The project demonstrates how a backend service can be built from the ground up without relying on high-level frameworks.


Overview

new_server is a systems programming project designed to explore how scalable servers are built internally. The server is written in C and handles networking, concurrency, and packet processing manually.

A Python client provides an interactive command interface that allows users to connect to the server, send commands, and interact with server functionality.

This project highlights experience with:

  • Linux systems programming
  • TCP socket communication
  • Event-driven server architecture
  • Concurrent processing using thread pools
  • Custom data structures
  • Binary packet serialization
  • Client/server communication

Project Structure

new_server/
│
├── include/                 # Header files
│   ├── epoll_lib.h
│   ├── error_handler.h
│   ├── hashmap.h
│   ├── linked_list.h
│   ├── server_core.h
│   ├── server_limits.h
│   ├── server_packet.h
│   ├── server_utils.h
│   ├── threadpool.h
│   └── user_lib.h
│
├── src/                     # Server source code
│   ├── epoll_lib.c
│   ├── error_handler.c
│   ├── hashmap.c
│   ├── linked_list.c
│   ├── main.c
│   ├── server_core.c
│   ├── server_packets.c
│   ├── server_utils.c
│   ├── threadpool.c
│   └── user_lib.c
│
├── client.py                # Python client interface
├── commander.py             # Command shell implementation
├── Makefile                 # Build automation
├── server_plan              # Design notes
└── test.sh                  # Basic test script

Features

Custom Server Implementation

The server is implemented entirely in C using modular components.

Epoll-Based Networking

Uses Linux epoll for efficient socket monitoring and event-driven I/O.

Thread Pool

A thread pool allows concurrent handling of client requests.

Binary Packet Handling

Communication between the Python client and server uses binary packet structures.

Session Management

The architecture supports session and user handling through a dedicated user library.

Custom Data Structures

The project implements internal data structures including:

  • Hash maps
  • Linked lists

Interactive Python Client

A Python command-line interface allows users to interact with the server.


Technologies Used

Server

  • C
  • POSIX sockets
  • epoll
  • pthreads
  • GNU Make
  • Linux system libraries

Client

  • Python 3
  • socket
  • struct
  • cmd module

Testing

  • Bash scripts

How the System Works

  1. The server listens for incoming TCP connections.
  2. Clients connect using the Python client interface.
  3. Commands are sent from the client using binary packets.
  4. The server processes requests using worker threads.
  5. Responses are returned to the client.

The architecture combines:

  • epoll-based socket management
  • thread pools for concurrency
  • modular server components

Build Instructions

Requirements

  • Linux
  • GCC
  • Make
  • Python 3

Build the Server

Run:

make

Debug Build

make debug

Clean Build Files

make clean

Running the Server

Start the server:

./capstone

Running the Client

Run the Python client:

python3 client.py

Specify IP and port if needed:

python3 client.py -i 127.0.0.1 -p 4567

Client Commands

Example commands:

connect
login <username> <password>
logout
quit

Example session:

$ python3 client.py -i 127.0.0.1 -p 4567

Successfully connected to 127.0.0.1:4567

> login admin password
> logout
> quit

Testing

A basic testing script is included:

./test.sh

This script repeatedly launches the client for simple testing.


Design Goals

This project explores low-level server architecture concepts including:

  • Socket programming
  • Event-driven networking
  • Concurrent request processing
  • Custom protocol design
  • Modular server design

The goal was to gain a deeper understanding of how backend services function at the systems level.


Future Improvements

Possible improvements include:

  • TLS encrypted communication
  • Improved authentication
  • Structured logging
  • Docker containerization
  • CI/CD integration
  • Automated testing
  • Performance benchmarking

Learning Outcomes

This project demonstrates experience with:

  • Linux systems programming
  • Network protocol design
  • Concurrent server architecture
  • Data structure implementation
  • Client/server communication

License

This project currently does not include a license. Consider adding an open-source license such as MIT or Apache 2.0 if you plan to distribute the code.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages