COMP2221 multi-threaded server
School of Computer Science: assessment brief
Module titleNetworksModule codeCOMP2221Assignment titleCoursework
- 1 Assignment guidanceFor this coursework, you will implement client and multi-threaded server applicationsfor a simple voting system in which the server is initialised with the options to votefor, and clients can view the current number of votes for each option. Clients can also
vote for one of the options, which is then updated on the serverThis coursework specification is for school Unix machines only, including the remoteaccess feng-linux.leeds.ac.uk. We cannot guarantee it will work on any otherenvironment.
- Assessment tasksTo get started, unarchive the file cwk.zip (you can do this from the command line
by typing unzip cwk.zip). You should then have a directory cwk with the followingstructure:cwk --- client --- Client.java|-- server --- Server.javampty .java files for the client and server have been provided. Do not change thenames of these files, as we will assume these file and class names when assessing.
You are free to add additional .java files to the client and server directories.The requirements for the server application are as follows:
- Accept at least two options that can be voted for, each consisting of a single word,as command line arguments when launched, e.g.java Server rabbit squirrel duck
- The server should immediately quit with an error message for less than two options.
- Otherwise, it should run continuously.
- Use an Executor to manage a fixed thread-pool with 30 connections.
- If the client makes a vote for <option>, the vote count for <option> should beincreased by 1 (note all vote counts should initially be zero).
- However, if <option> does not exist, an error message should be returned.
- Following a request by a client, return the current state of the poll with one lineper option, where each line contains at least the option and the current count. See
below for an example of valid output.
- Create the file log.txt on the server directory and log every valid client request,with one line per request, in the following format:date|time|client IP address|requestwhere request is one of list or vote, i.e. you do not need to log the option forvote operations. Do not add other rows (e.g. headers, blank lines) to the log file.
Note that you must create the log file, not overwrite or append an existing file. Anylog.txt file in your submission will be deleted at the start of the assessment.The requirements for the client application are as follows:
- Accept one of the following commands as command line arguments, and performthe stated task:
2• list, which displays the current state of the poll from the server and displaysit to the user. Each option should be output on the same line as their currentvote count, with a different line for each option. See below for an example ofvalid output.
- vote <option>, which requests that the server increases the vote count for<option> by 1, and display the message returned by the server.
- Exits after completing each command.Your server application should listen to the port number 7777. Both the client and the
server should run on the same host, i.e. with hostname localhostAll communication between the client and server must use sockets – they cannot accesseach other’s disk space directly. Your solution must use TCP, but otherwise you arefree to devise any communication format you wish, provided the requirements aboveare met.Neither the client nor the server should expect interaction from the user once they areexecuted. In particular, instructions to the Client application must be via commandline arguments. 代写COMP2221 multi-threaded serverIn the case of an invalid input, your client application should quit witha meaningful error message.
- General guidance and study supportIf you have any queries about this coursework, visit the Teams page for this module. Ifyour query is not resolved by previous answers, post a new message.Support will also
be available during the timetabled lab sessions.You will need the material up to and including Lecture 11 to complete this coursework.
You may like to first develop Client.java and Server.java to provide minimal func
tionality, following the examples covered in Lectures 7 and 8. You could then addnother class that handles the communication with a single client. This will makeit easier to implement the multi-threaded server using the Executor. Multi-threadedservers were covered in Lectures 10 and 11. You will need to use input and outputstreams; these were covered in Lecture 6.Example sessionFirst cd to cwk/server, compile, and launch the server with two options to vote for:
> java Server rabbit squirrelNow in another tab or shell, cd to cwk/client and compile. If you execute the followingcommands, the output should be something like that shown below.
>java Client list
’rabbit’ has 0 vote(s).
’squirrel’ has 0 vote(s).
> java Client vote rabbitIncremented the number of votes for ’rabbit’.
>java Client list
’rabbit’ has 1 vote(s).
’squirrel’ has 0 vote(s).
3> java Client vote duck
Cannot find option ’duck’.Note your application does not need to follow exactly the same output as in this example, as long as the requirements above are followed.
- Assessment criteria and marking processYour code will be checked using an autograder on Gradescope to test for functionality.Staff will then inspect your code and allocate the marks as per the provided markscheme below. This includes the meaningful nature (or not) of error messages outputby your submission.
- Submission requirementsRemove all extraneous files (e.g. *.class, any IDE-related files etc.). You should then
archive your submission as follows:(a) cd to the cwk directory
(b) Type cd ..
(c) Type zip -r cwk.zip cwkThis creates the file cwk.zip with all of your files. Make sure you included the -roption to zip, which archives all subdirectories recursively.To check your submission follows the correct format, you should first submit using thelink Coursework: CHECK on Gradescope. Only once it passes all of the tests should
you then submit to the actual submission portal, Coursework: FINAL.The autograder is set up to use the standard Ubuntu image (base image version 22.04)with OpenJDK 21 installed as follows,linux.leeds.ac.uk.The following sequence of steps will be performed when we assess your submission.
(a) Unzip the .zip file.
(b) cd to cwk/client directory and compile all Java files: javac *.java
(c) cd to cwk/server directory and do the same.
(d) If there is a log.txt file on the server directory, it will be deleted.
(e) To launch the server, cd to the cwk/server directory and type e.g. java Servermouse rabbi(f) To launch a client, cd to the cwk/client directory and type e.g. java Clientlist
If your submission does not work when this sequence is followed, you will lose marks.Academic misconduct and plagiarism
Academic integrity means engaging in good academic practice. This involves essentialacademic skills, such as keeping track of where you find ideasandinformation andreferencing these accurately in your work.4By submitting this assignment you are confirming that the work is a true expressionof your own work and ideas and that you have given credit to others where their workhas contributed to yours.
There is a three-tier traffic light categorisation for using Gen AI in assessments. Thiassessment is amber category: AI tools can be used in an assistive role. Use commentsin your code to declare any use of generative AI, making clear what tool was used andto what extent.Code similarity tools will be used to check for collusion, and online source code siteswill be checked.Assessment/marking criteria grid