Question: Q8- Change the client program code with name labl4q8_client.c such that user enters 2 inputs: A floating point number for the temperature value A character:
Q8- Change the client program code with name "labl4q8_client.c" such that user enters 2 inputs: A floating point number for the temperature value A character: Either C of F for the temperature type Also, change the server code with name "lab I 4q8_server.c" such that: if the character received was C it should convert the floating point number from Celsius to Fahrenheit, and if F then it should go vice versa. Then, the server should send the proper message to the client side, either: Server: Temperature in x Celsius = y Fahrenheit Or, Server: Temperature in x Fahrenheit = y Celsius Finally, the server closes the connection and loop back for a new client. The program should check and report properly with clear messages for any system errors in both the client and server programs. a- Include the source files in your report.
b- Show the commands to compile and link them with the names "labl4q8_client" and "labl4q8_server".
c- Open two terminals and do the following:
First terminal: execute the server program like:
./labl4q8_server 2222
Second terminal: execute the client program like:
./ lab14q8_client 127.0.0.1 2222
Test the client/server exchange of messages. Show three run outputs in your report for two correct cases ( C and F) and one wrong client request format.



server1 typedef struct sockaddr SA; int open_listenfd(char *port) t struct addrinfo hints, listp, *p; int listenfd, rc, optval-1; memset (&hints, 0, sizeof (struct addrinfo)); hints, ai-soc ktype = SOCK-STREAM; , hints.ai flags AI_PASSIVE AI_ADDRCONFIG; hints.ai_flags |- AI NUMERICSERV; if ((rc getaddrinfo(NULL, port, &hints, failed &Iistp)) %s): != 0) %s ", { fprintf(stderr, exit (1); (p "getaddrinfo (port port, gai_strerror(rc)); listp; ((listenfd p->ai-next ) socket(p->ai-family, for p; p { = if p-ai. Socktype, p->ai-protocol)) = ", argv[0]); listenfd -open_listenfd(argv[1]); while (1) clientlen sizeof(struct sockaddr connfd - accept (listenfd, (SA )&cl getnameinfo( (SA) &clientaddr, clientlen, client_hostname, MAXLINE, _storage); ientaddr, &clientlen); client_port, MAXLINE, 0) Page 1 server1 typedef struct sockaddr SA; int open_listenfd(char *port) t struct addrinfo hints, listp, *p; int listenfd, rc, optval-1; memset (&hints, 0, sizeof (struct addrinfo)); hints, ai-soc ktype = SOCK-STREAM; , hints.ai flags AI_PASSIVE AI_ADDRCONFIG; hints.ai_flags |- AI NUMERICSERV; if ((rc getaddrinfo(NULL, port, &hints, failed &Iistp)) %s): != 0) %s ", { fprintf(stderr, exit (1); (p "getaddrinfo (port port, gai_strerror(rc)); listp; ((listenfd p->ai-next ) socket(p->ai-family, for p; p { = if p-ai. Socktype, p->ai-protocol)) = ", argv[0]); listenfd -open_listenfd(argv[1]); while (1) clientlen sizeof(struct sockaddr connfd - accept (listenfd, (SA )&cl getnameinfo( (SA) &clientaddr, clientlen, client_hostname, MAXLINE, _storage); ientaddr, &clientlen); client_port, MAXLINE, 0) Page 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
