|
CS473 - Computer Networks
| Displaying exercises/e5/files/host.c
/* Includes go here */
/* host.c:
* A program to print the IP address of a host specified on the command
* line. If no argument is provided, print a usage message and exit.
* Example input/output:
* > ./host www.indstate.edu
* Host: www-prod-cms-lb.indstate.edu
* Aliases:
* www.indstate.edu
* Host type: IPv4
* Addresses:
* 139.102.15.65
*/
int main(int argc, char *argv[])
{
/* man 3 gethostbyname for information on the hostent structure: */
/**
* Use the gethostbyname(3) function to look-up the host provided on the
* first command line argument (argv[1]), assign the result to host. If
* host is NULL, print "Host not found: " followed by name of the host and
* exit with a value of 1:
*/
/* Print the name of the host: */
/**
* If h_aliases[0] is not null, then print a list of aliases, otherwise don't:
* (there may be more than one, ex: cs.indstate.edu while logged into CS)
*/
/* Print the host type (IPv4 or IPv6). */
/**
* Print the addresses, there may be more than one: (ex: amazon.com)
* Use the inet_ntop(3) function to write the IP-address into a buffer, then
* print the string found in the buffer.
*/
return 0;
}
|