Skip to content

About

Multi-client TCP chat application developed in C using SDL_net. The server manages multiple client connections and broadcasts messages to all connected clients, providing a real-time chat experience.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Client TCP Chat

Description

This project is a simple, terminal-based multi-client TCP chat application, developed using the C programming language and the SDL (Simple DirectMedia Layer) library, specifically the SDL_net module. Clients can connect to the server, send and receive messages, and chat in real time.

Features

  • Supports up to 10 clients connected simultaneously.
  • Allows clients to set a username when connecting to the server.
  • Messages sent by clients are broadcast to all connected clients (except the sender).
  • Uses TCP protocol for reliable, connection-oriented communication between clients and server.
  • Utilizes SDL_net for managing network connections and socket communication.

Built With

C SDL

Visuals

demo.mp4

Installation

To get started with this project, follow the steps below:

  1. Install build tools and SDL libraries

    • Debian/Ubuntu:

      sudo apt install gcc make libsdl2-dev libsdl2-net-dev
      
    • Fedora/RHEL/CentOS:

      sudo dnf install gcc make SDL2-devel SDL2_net-devel
      
    • OpenSUSE:

      sudo zypper install gcc make SDL2-devel SDL2_net-devel
      
    • Arch Linux:

      sudo pacman -S gcc make sdl2 sdl2_net
      
    • If your Linux distribution is not listed, you can find instructions for installing the SDL libraries from source here.

  2. Clone the repository

    git clone https://github.com/cristianscheid/multi-client-tcp-chat.git
    cd multi-client-tcp-chat
    
  3. Build the project

    make
    

Usage

  1. Start the server

    ./build/server
    
    • You should see the message: "Server is up and running."
    • The server listens on 127.0.0.1:2000 (localhost).
  2. Optional - Change the server address on the client (for connections from another machine)

    • By default, clients connect to 127.0.0.1 (localhost).
    • To connect from another machine, modify the SERVER_HOST constant in src/client.c with the server's IP address.
    • After making the change, run make clean and make to rebuild the project.
    • Ensure the firewall on both the server and client allows traffic on port 2000.
  3. Start the client(s)

    ./build/client
    
    • You should see the message: "Welcome to the Multi-Client TCP Chat!"
    • Open a new terminal for each client you want to connect (up to 10 clients).
  4. Interact with the clients

    • Set your name and send messages in the chat.
    • The server will display all received messages.
    • Clients will see messages sent by others.
  5. To stop

    • Press Ctrl + C to stop the server or exit a client.

License

Distributed under the MIT License. See LICENSE.txt for more information.

About

Multi-client TCP chat application developed in C using SDL_net. The server manages multiple client connections and broadcasts messages to all connected clients, providing a real-time chat experience.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages