In this assignment, you will use sockets to write a simple client-server application using UDP sockets to obtain your coursework marks. You should input your student ID number and password from the client and if the ID and password match a record held by the server, the server will send your coursework marks to you. The client/server action should proceed as follows:

Client

  • c1. Connect to server using connectionless communication via a UPD 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 password and send them 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

Server

  • s0. [Initialization] Create a socket on one of the port numbers in the range above 1024.
  • s1.Wait for a client connection on this UDP socket
  • s2.When a client connection is accepted, send an acknowledgement as a string of text.
  • s3. Receive and read the student ID number and password sent by the client. Check that this student ID and password 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.

Programming notes

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 and password are 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, password 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.

Extensions

A small number of marks are reserved for extensions. Such as making a concurrent Client/Server system (services are available to multiple clients, multithreaded, with Java™ security features etc.)

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be 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 complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.