Skip to content

A lightweight TCP server implementation in C

aiexit/tcp-server-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCP Server in C

A lightweight, efficient TCP server implementation in pure C. This project provides a simple echo server with a client example for testing.

Features

  • ✨ Simple and clean C implementation
  • 🚀 Lightweight and fast
  • 🔌 Configurable port
  • 📡 Echo server functionality
  • 🧪 Includes test client
  • 🛠️ Easy to build with Makefile

Building

make

This will compile both the server and client executables.

Usage

Server

Run the server with default port (8080):

./tcp_server

Or specify a custom port:

./tcp_server 9000

Client

Connect to server on localhost:

./tcp_client

Connect to a specific server and port:

./tcp_client 192.168.1.100 9000

Testing with netcat

You can also test the server using netcat:

nc localhost 8080

Architecture

  • tcp_server.c: Main server implementation with connection handling
  • tcp_client.c: Simple client for testing server functionality
  • Makefile: Build configuration

Configuration

Default settings in tcp_server.c:

  • PORT: 8080
  • BUFFER_SIZE: 1024 bytes
  • MAX_CLIENTS: 10 concurrent connections

Future Enhancements

  • Multi-threaded connection handling
  • SSL/TLS support
  • Custom protocol implementation
  • Connection pooling
  • Logging system

License

MIT License

Author

Created with ❤️ for learning and development

About

A lightweight TCP server implementation in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published