In this assignment, you will use sockets to write a simple client-server application to obtain your coursework marks. You should input your student ID number from the client and if this ID matches a record held by the server, the server will send your coursework marks to you. The client/server action should proceed as follows:
c1. Connect to server via a connection-oriented (TCP) socket.
c2. Read (from socket) and display the prompt message sent (see step s2 in server) by the server.
c3. Input your ID number and send it to the server.
c4.Read (from socket) and display your coursework mark, an error message that is returned by the server (see step s4 in server).
c5. Close the connection
s0. [Initialization] Create a socket on one of the port numbers in the range above 1024.
s1.Wait for a client connection on this socket
s2.When a client connection is accepted, send an acknowledgement as a string of text.
s3. Receive and read the student ID number sent by the client. Check that this student ID is valid, if not, return an error message.
s4. Find the coursework mark requested and send to the client.
s5. Close the connection to the client and then loop back and wait for another connection.
Here are a few tips/thoughts to help you with this assignment:
You must choose an unused server port number above 1024. For example, choose port 8888.
The Server application listens on port 8888 and handles the incoming requests. It may consist of several classes, one to listen, accept connections and revert to listening, and one to check whether received ID is valid. The Server should print diagnostic information on the terminal (no GUI is required), listing the status of the server and details of each connection. For example: Server listening on Port 8888, IP number of Client, Connection accepted. It may be helpful to test your Server using telnet before attempting to connect to the client.
Write a Client application, which consists of a GUI containing a field to insert the student ID and a ‘Submission’ button that must be clicked to send it. A 'Quit' button would also be good programming practice.
Most of you will be running both the client and server on the same machine. Start the server in one window, and then start the client in another window. In the socket, use ‘localhost’ as the name of the machine to connect to.
Make sure you close every socket that you use in your program. If you abort your program, the socket may still hang around and the next time you try and bind a new socket to the port you previously used (but never closed), you may get an error. Also, please be aware that port number, when bound to sockets, are systemwide values and in the Linux lab other students may be using the port number you are trying to use.
A small number of marks are reserved for extensions. Such as making a concurrent Client/Server system (services are available to multiple clients, multithreaded).
Write a report on the design and implementation of your solution, showing code and results: (i) a class diagram outlining the class structure for your proposed solution. (ii) a set of summary tables describing the fields, constructors and methods for each class. (iii) a print out of the Java source code of your complete program.
It is not our intention to break the school's academic policy. Projects posted are only used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly fill out the form.
Please provide a valid email address and we'll get back to you in less than 24 hours.
We will be sending an invoice through PayPal upon confirmation.
We are a non profit organization however we need an amount to keep this organization running,
and to be able to complete our research and development.