Overview

This homework assignment involves writing a multithreaded name service client-server application. In this application, the client will write an IP name (i.e. www.geni.net) and the server will respond to the client with the IP address (i.e. 128.163.140.180).

DNS

DNS (Domain Name System) is used to resolve IP names to actual IP addresses. The following program illustrates how DNS can be used:

  • DNSLookUp.java

Usage:

java DNSLookUp < host >

The Server

This server will operate as follows:

  • It will listen to port 6052.
  • When a connection is made, is will service the client in a separate thread.
  • Once the server reads the IP name from the client, it looks up its corresponding IP address, and writes it back to the client. The IP address will be written as a string, and terminated by a newline \r\n.
  • The server will then close the socket connection.

If the server cannot resolve the IP name to an address, it will write the message Unknown Host followed by a newline \r\n.

The Client

The client will be passed two parameters:

1. The IP address the server is running on (i.e. localhost, although it could also be a server running on another machine.)

2. The IP name to be resolved.

As an example:

java DNSClient localhost www.westminstercollege.edu

Where the client writes the corresponding IP address it read from the server:

146.86.4.37

If the client were to enter an invalid IP name, such as:

java DNSClient localhost www.nosuchcollege.edu

The server would return the message

Unknown Host

and the client would display this message it received from the server.

Error Checking

Standard error checking applies:

  • Make sure that exactly the correct number of parameters are passed to the client.
  • Be sure to close all connections on both the client and server.

Additionally, it is important that your program only return the IP address, or the message Unknown Host. No other messages should be returned to the client.

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.