(Solved) : Serverc Clientc Pair Code Makes Use Fifo Transit Characters Client Side Server Side Modify Q42744058 . . .

The server.c and client.c pair of code makes use of FIFO and can only transit characters from the client side to the server side. Modify the source code so that every time the server side receives information from the client side, the server side send an acknowledgement to the client side to display. For example, the user at the client side types a letter “a”, and the server side displays the letter “a”, and the server side sends the sentence “I received your message” to the client side so that the client side displays “I received your message” in its console.SERVER.C FILE#include <fcntl.h>#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <sys/stat.h>// This is the serverint main(int argc, char *argv[]){ int fd; char ch; unlink(“../myserver”); // delete it if it exists if(mkfifo(“../myserver”, 0777)!=0) exit(1); while(1){ fprintf(stderr, “Waiting for a clientn”); fd = open(“../myserver”, O_RDONLY); fprintf(stderr, “Got a client: “); while(read(fd, &ch, 1) == 1) fprintf(stderr, “%c”, ch); }}

CLIENT.C FILE

#include <fcntl.h>#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <sys/stat.h>int main(int argc, char *argv[]){ int fd; char ch; while((fd=open(“../myserver”, O_WRONLY))==-1){ fprintf(stderr, “trying to connectn”); sleep(1); } printf(“Connected: type in data to be sentn”); while((ch=getchar()) != -1) // -1 is CTRL-D write(fd, &ch, 1); close(fd);}

Expert Answer


Answer to The server.c and client.c pair of code makes use of FIFO and can only transit characters from the client side to the se…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us