You are requested to implement a client-server Java application allowing a client to request from a server the location information regarding services provided within KSU. Java TCP socket programming will be used for this purpose. The protocol to be implemented by the pair of programs (client and server) is summarized below:

Client side:

  • The client starts by prompting the user to type a server name.
  • Once a TCP connection with the server is set, the message “Enter a service name” is displayed on the client’s screen requesting the user to type a service name, like: restaurant, copy-center, fast-food, etc.
  • Once the user types a service name, the corresponding text is uppercased by the client and sent to the server.
  • On receiving the service location text from the server (like, Building31, etc.) the client will display this text on the screen. Then, the message “Enter a service name” is again displayed on the client screen.
  • Steps 3-4 will be repeated until the user type the word Exit which closes the TCP connection and terminate the client program.
    • The word Exit will also be sent to the server to close the underlying TCP connection on the server side.

Server side:

  • The server starts by prompting an administrator to enter a service name. Then, the server will ask the user to provide its location(s). Service name texts and the service location(s) texts will be stored uppercased in arrays.
    • Suggestion: use two independent arrays, one for the service name and the other for the service location. We will use the same index on both arrays in order to locate a certain service name and its corresponding location(s).
  • The server loops on step 1 until the administrator type the word Terminate.
  • The server then blocks waiting for a connection from any client on port 1234.
  • Once a TCP connection with a client has been set, the server will display the IP and the port number of the current remote client to the server.
    • Hint: Look for the available methods of the Socket class to display the requested information.
  • The server reads the client’s requested service name, makes a table look-up to find the location(s) of the service if available, and finally sends the appropriate answer (i.e. service location) to the client.
  • The server will loop around step 5 until receiving the word Exit from the client which will terminate the TCP connection with that client.
  • The server will then return to step 3 waiting for another client connection request.
Academic Honesty!
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.