top of page

Build a socket-based client-server system

Sockets are commonly used for client and server interaction. Typical system configuration places the server on one machine, with the clients on other machines. The clients connect to the server, exchange information, and then disconnect. A socket has a typical flow of events.


Requirements

At any point in time, exactly one player has the virtual ball. This player needs to decide who to pass the bass to. (they are allowed to pass the ball to themselves). Once the decision is made, they pass the ball to the corresponding player.


New players can join the game at any time. The number of players in the game is unlimited. Every player joining the game has to be as signed a unique ID that will not change until they leave the game and will not be reused after they leave the game. All the players including the one with the ball will immediately learn about new players and,

hence, the current ball owner can decide to pass the ball to the player

who has just joint the game.


Any player can leave the game at any time (the client application can be closed/killed). If the player with the ball leaves the game, the server passes the ball to one of the remaining players. If there are no players in the game, the server waits until someone

joins the game in which case the first player to connect receives the ball.


Client User Interface

Each client has to display their own ID, information about all the players currently in the game and the ID of the player currently having

the ball. The client should also be prompting a message to the player

that currently has the ball, asking them the ID of the player that

they’d like to pass the ball to (e.g. “Whom would you like the ball to?

Enter ID”).


Server User Interface

>Player joining the game (display the ID of the new player and

the list of players currently in the game).

> Player leaving the game (display the ID of that player and the

list of players currently in the game).

> The ball being automatically passed to one of the players after

the player with the ball left the game (display the ID of the new

player with the ball).

> Player passing the ball to another player (display the IDs of

both players).


Implementation -

Please note that the core requirement of the assignment is to Implement the client-server architecture using sockets. The server and each player have to run in separate processes (not thread!). Submission with a single process running all the players will lose a lot of points. Also, the emphasis should be on reliability. For example, if two players leave at the same time, or a client process is killed (not closed "correctly"), this should be handled correctly.


There has to be server-side validation of data. For example, if player A passes the ball to player B but player B leaves just before that, the server should prevent this, e.g., by returning the ball to A.


Only command line interfaces are expected, so there is no need to implement a graphical user interface. You will *not* be awarded extra marks if you implement functionalities that were not required in the assignment (e.g. no extra marks for a GUI).


If you are looking for any kind of coding help in programming languages, Contact us for instant solution



bottom of page