Your assignment is to construct a testing tool for network services. The program accepts as input three command line arguments. The first is the transport type, TCP or UDP. The second is the IP address of the service. The third is the service name or port number. After being invoked, the program waits for input from the user. As each line of input is entered, the program sends it to the service. Any responses sent back from the service should be displayed. The tool should handle error messages for hosts and services not being found. The tool should wait 15 seconds for a response. If a response is not received, then an error message should be printed and the program should exit.
nstest TCP naur 80
should connect to naur using TCP on port 80 and wait for input from the user. Below is some sample input and output.
Input: HEAD /~tmont HTTP/1.0
Output:
HTTP/1.1 301 Moved Permanently
Date: Wed, 17 Feb 1999 22:29:59 GMT
Server: Apache/1.3.3 (Unix) PHP/3.0.5
Location: http://www.csee.wvu.edu/~tmont/
Connection: close
Content-Type: text/html
For extra credit, make your tool understand the UNIX argument style for transport, port/service, and wait timeout [+3%]. And/Or add the ability to specify hexadecimal input and display hexadecimal output. [+4%]