Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C Socket GroupChat

A lightweight multi-client TCP chat application built from scratch in C, using raw BSD sockets and POSIX threads (pthreads). It demonstrates low-level network programming concepts including socket creation, binding, listening, accepting connections, and concurrent client handling.

Features

  • TCP server that accepts multiple simultaneous client connections
  • Thread-per-client architecture: each connected client is handled on its own detached pthread
  • TCP client with a simple CLI: type a message and hit Enter to broadcast it
  • Basic message framing over the TCP stream

How it works

  • The server creates a listening socket and spawns a dedicated thread to accept incoming connections.
  • Each accepted connection is handed off to its own thread, which listens for incoming data and prints it.
  • Clients connect via connect(), send their username once, then stream chat messages line by line.

Tech stack

  • Language: C
  • Networking: POSIX sockets (socket, bind, listen, accept, connect, send, recv)
  • Concurrency: POSIX threads (pthread_create, pthread_detach)

Build & Run

# Server
gcc SocketServer.c -o SocketServer -lpthread
./SocketServer

# Client
gcc Client.c -o Client -lpthread
./Client

Roadmap / Next steps

  • Broadcast messages to all connected clients (currently server-side only)
  • Migrate from thread-per-client to select()/poll() for scalability
  • Message framing/delimiting for reliable parsing over TCP streams
  • IPv6 support

Author

Built as part of a self-taught journey into systems & network programming in C.

About

A multi-client TCP chat server written in C using raw sockets and POSIX threads. Each client connection is handled on a dedicated thread, enabling real-time group messaging over a simple socket protocol.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages