Skip to content

biraj21/tcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TCP Server in C

This is a basic single-threaded TCP server with an event loop using the poll system call, written in C, without any third-party library, solely relying on native C functionalities. The server listens on a port and echoes back received data. I've also written a simple client to test the server.

I've followed the tutorial at Beej's Guide to Network Programming to gain an understanding of sockets before writing this server. I followed The Event Loop Implementation to understand how to implement an event loop using poll. I also watched Johannes 4GNU_Linux's YouTube video to understand how to implement a simple event loop in C.

How to run

  1. Clone the repository

  2. Compile client and server programs (don't worry, there's a Makefile to do this for you)

    make
  3. Run the server (it will run on port 3000)

    ./bin/server
  4. Run the client in another terminal

    ./bin/client
  5. Type something in the client terminal and press enter. You should see the server echoing back what you typed.

  6. Ctrl+C to stop the server and client.

Resources:

About

A single-threaded TCP server with an event loop using the poll system call written in C.

Resources

Stars

Watchers

Forks