Server-Client Multiplayer based game in C

Project Details


Introduction

The goal of this project was to understand the basis of sockets, fork and threads in C programming.
The project aims to design, simulate, and test a simple console game to work with threads and sockets.


Project Overview

The project involves:

  • Understanding the concept of forks and threads
  • Understanding sockets and multiplayer management
  • Designing a Server-Client application
  • Using the GCC flags -ansi -pedantic -Wall to write standard-compliant code

General Description of the Project

Multiplayer Client/Server Typing Speed Game

  • The player who types the most words correctly wins
  • Originality:
    • Ability to start the game with a variable number of users (from 1 to NB_CLIENT_MAX players, as long as everyone is ready)
    • Time management handled in a separate thread
    • Score and ranking management with a variable number of clients

Code Structure

To maintain clarity in digital system design projects, it is essential to separate source code from test benches and compiled files:

Project Directory Tree

Figure 3: Project directory structure

  • appli: contains client.c, serveur.c, and liste_francais.txt (word list)
  • include: contains the headers of the modules
  • modules: contains the PSE modules used plus words.c
  • lib: contains libpse.a, the static library of the PSE modules

Server

The server is the central element of the game. It manages the game, the players, and the game statistics.

Server Flowchart

Figure 2: Server Flowchart


Client

The client is the player. It connects to the server and plays the game.

Client Flowchart

Figure 3: Client Flowchart