Lab 10
[valid 2025-2026]
Networking
Create an implementation of a multiplayer quiz game.
The application will contain two parts (create a project for each one):
- The server is responsible for accepting players, sending questions, receiving answers, checking correctness, updating scores, broadcasting results, etc.
- The client will communicate with the server by sending commands such as joining a game, submitting a response, displaying scores, etc.
The main specifications of the application are:
Compulsory (1p)
- Create the project ServerApplication. This will contain (at least) the classes: GameServer and ClientThread.
- Create the class GameServer. An instance of this class will create a ServerSocket running at a specified port.
The server will receive requests (commands) from clients and it will execute them.
- Create the class ClientThread. An instance of this class will be responsible with communicating with a client Socket.
If the server receives the command stop it will stop and will return to the client the response "Server stopped", otherwise it returns: "Server received the request ... ".
- Create the project ClientApplication. This will contain (at least) the class: GameClient.
- Create the class GameClient. An instance of this class will read commands from the keyboard and it will send them to the server.
The client stops when it reads from the keyboard the string "exit".
Homework (2p)
- Design a text format for storing the questions and their correct answers.
- Create the OOP model and implement the game functionalities.
- The server should use a thread pool executor and implement graceful shutdown.
- Implement real-time communication. The client needs at least two threads:
- One thread reads keyboard input and sends it to the server.
- Another thread listens for messages from the server.
- The games will be played under time control (blitz), with each player having a specific amount of time to answer a question.
- Determine the winner by evaluating correctness and breaking ties using the total response time.
Advanced (2p)
- Consider the case where a game may include both human and bot players. Implement the following types of bot players:
- Random AI
- Custom AI with a knowledge base and supervised learning
- LLM-based AI with difficulty levels (use an external API)
- (+1) Create a scenario that demonstrates that using virtual threads to manage client connections (one client connection = one virtual thread) may be a better approach than using platform threads.
You should be able to launch a game with a very large number of clients, playing concurrently within a very short time.
Resources
Objectives
- Understand the terms and concepts related to networking: protocol, IP, port, URL, socket, and datagram.
- Become familiar with the client-server programming model.
- Write programs that communicate with other programs over the network using TCP or UDP.
- Communicate with web resources over HTTP.