首页 > > 详细

COMP2221 Coursework 2

 COMP2221 Coursework 2 1 School of Computing, University of Leeds COMP2221 Networks Coursework 2: Using sockets to transfer files Deadline: 10am, Monday 22nd March If you have any queries about this coursework, visit the Microsoft Teams page for this module. If your query is not resolved by previous answers, post a new message. Learning objectives • Implementation of client and multi-threaded server applications. • Design of a communication protocol to meet the specified requirements. • Use of sockets to transfer text from server to client. Task Write two applications, a server and a client, that permit the listing of text files on a pre-defined directory on the server, and the transfer of these files from the server to the client, all using sockets. The server application should: • Run continuously. • Use an Executor to manage a fixed thread-pool with 15 connections. • Following a request by a client, query the local folder serverFiles and return a list of the files found there to the same client. • Send a text file from serverFiles to a client that requests it. • Create the file log.txt on the server directory and log every client request, with one line per request, in the following format: date:time:client IP address:request. The client application should: • Accept one of the following commands as command line arguments, and performs the stated task: – list, which lists all of the files on the server’s folder serverFiles. – get fname, which requests the server send the file fname. This should then be read and saved to the client’s local directory. • Exits after completing each command. Your server application should listen to a port number in the range 8000 to 8999, but otherwise you are free to choose the port number. Your solution should work in principle for any text files,

COMP2221 Coursework 2 2 not just those provided. Only text files need be transferred; there is no need to consider binary file transfer. You solution must use TCP, but other details of the communication protocol between the server and its clients are not specified. You are free to devise any protocol you wish, provided the above requirements are met. Both the client and the server should run on the same machine, i.e. with hostname localhost. They should not attempt to access each other’s disk space directly; all communication must be via sockets. When accessing local files, ensure UNIX filenames only are used (e.g. do not use Windows’ backslashes), as your submission will be tested on a School Linux machine. All interaction with the Client application must be via command line arguments. Any other form of input (e.g. a keyboard scanner) will result in a loss of marks. In the case of an invalid input, your client application should quit with a meaningful error message. Both applications should have basic error handling and your code should adhere to the Java coding standards described in JavaCodingStandards.pdf on Minerva. Guidance Download the file cwk2.tar.gz from Minerva and unarchive it using tar xzf cwk2.tar.gz. You should now have a directory cwk2 containing the following files and subdirectories: cwk2 --- client --- Client.java |-- server --- Server.java |-- serverFiles --- lipsum1.txt |-- lipsum2.txt Empty class files for the client and server have also been provided. Do not change the names of these files, as we will assume these file and class names when assessing (see below). You are free to add additional .java files to the client and server directories but your submission must work when the procedure described below is followed. You are also provided with some example text files to transfer from the server, lipsum1.txt and lipsum2.txt. You may like to first develop Client.java and Server.java to provide minimal functionality, following the examples covered in Lectures 7 and 8. You could then add another class that handles the communication with a single client. This will make it easier to implement the multi-threaded server using the Executor. Multi-threaded servers were covered in Lectures 10 and 11. Input and output streams were covered in Lecture 6. It is not recommended that you chain multiple times from the same stream (e.g. chain two output streams from socket.getOutputStream()), as this can cause ill-defined behaviour.
COMP2221 Coursework 2 3 Marks This coursework will be marked out of 25. 5 marks : Basic operation of the Server application, including use of thread pool and log file output. 10 marks : Implementation of the list and get commands. 4 marks : Meaningful error messages from the client application. 6 marks : Good structure and commenting. Adherence to the Java coding standard provided. Total: 25 Submission Remove all extraneous files (e.g. *.class, any IDE-related files etc.). You should then archive your submission as follows: 1. cd to the cwk2 directory 2. Type cd .. 3. Type tar czf cwk2.tar.gz cwk2/* This creates the file cwk2.tar.gz that you should submit via Minerva. The following sequence of steps will be performed when we assess your submission. 1. Unarchive the .tar.gz file. 2. cd to cwk2/client directory and compile all Java files: javac *.java 3. cd to cwk2/server directory and do the same. 4. To launch the server, cd to the cwk2/server directory and type java Server 5. To launch a client, cd to the cwk2/client directory and type java Client 6. Multiple clients will be launched. Your submission must work when this sequence is followed on a School machine. Disclaimer This is intended as an individual piece of work and, while discussion of the work is encouraged, what you submit should be entirely your own work. Code similarity tools will be used to check for collusion, and online source code sites will be checked.
联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!