HOMEWORK 6: Myping Client/Server The intent is to implement a client/server service that will respond whether a remote host is up or not. The code will be implemented using sockets. Example of usage. A user who types: >myping websol10 accesses the myping client which contacts the myping server on websol10. The user would get the response: myping: websol10 10:31am up 4 day(s), 17:26, 2 users, load average: 0.00, 0.00, 0.02 The myping server running on a host cpu (like websol10) listens at its well-known port for client requests. The server forks a child to respond to the request. The original server process continues listening at the socket. Assume that the myping well-known port number is defined by the constant MYPINGPORT. myping_client.c - The client takes the host name as a command_line argument, makes a connection to the MYPINGPORT, reads what comes in on the connection, echoes it to stdout until the EOF, closes the connection, and exits. Assume that if the connection fails, the client sleeps for SLEEPTIME seconds and then retries. After the number of connection attempts without success exceeds RETRIES, the client outputs the message that the host is not available and exits. myping_server.c - The server listens for connections on the MYPINGPORT. If a connection is made, the server forks a child to handle the request and the original process resumes listening at MYPINGPORT. The child closes the listening socket descriptor, call the process_ping function, closes the communication socket descriptor and exits. process_ping.c - The process_ping() function has the following prototype: int process_ping(int commsockdes); The function writes the server's response to the communication socket descriptor. The response is one line, where the first field is the hostname and the rest of the line is the output from executing the "uptime" shell command. The hostname can be obtained using the uname() function (man -s2 uname): #include int uname(struct utsname *name); uname() uses the structure utsname defined in whose members include: char sysname[SYS_NMLN]; char nodename[SYS_NMLN]; char release[SYS_NMLN]; char version[SYS_NMLN]; char machine[SYS_NMLN]; uname() returns a null-terminated character string naming the current operating system in the character array sysname. Similarly, nodename contains the name that the system is known by on a communications network. You'll want the nodename field. Use the system() function to execute the "uptime" shell command (man uptime). uptime writes to standard output, so use dup2() to redirect stdout to the communication socket descriptor before issuing the system() function call. After the system() function call returns, the server child should exit. What to e-mail to me: myping_client.c myping_server.c (2 files)