Assignment 2

  1. Download the source code from the author's website. Extract the source code files into your local machine with the following command:

    % tar xvfz unpv12e.tar.gz

    A directory unpv12e will be created. In directory ./unpv12e/intro, you can find the souce code for the daytime server. Starting from daytimetcpsrv3.c and daytimetcpcli3.c, you are required to build your own daytime server and client.

    Some requirements should be followed:

    1. No user defined header files, such as unp.h, should be used.
    2. A makefile should be supplied to build the server and the client. The makefile should compile the souce code files and generate two executables: daytimetcpsrv3 for the server, and daytimetcpcli3 for the client. The target to build the application is daytime, which means one can type the following command to build the application:

      % make daytime

  2. Write a program to accomplish the domain name resolution. The program has the following syntax:

    % gethost [-r] name

    When there's no option, this program prints all the IP addresses for a host whose name is specified by name in the command.

    When option -r is present, the program accepts an IP address in the dotted notation form and prints all the domain names for this IP address.

    Your program should detect all possible invalid names.

    You should share the makefile of the above daytime application. The target to build the executable is gethost. The source code file should be gethost.c, or gethost.cc. The name of the executable should be gethost.


Note:
Hosted by www.Geocities.ws

1