Question
Q2) from assignment 3 An echo process echoes back whatever it receives from another process back to it. Write a C program using ordinary anonymous
Q2) from assignment 3 An echo process echoes back whatever it receives from another process back to it. Write a C program using ordinary anonymous pipes in which one process continuously inputs a string (i.e., a character array) from the user via the keyboard, sends the string to a second process, and the second process reverses the characters in the string message received, and sends the reversed string back to the first process, i.e., echoes back in reverse form. For example, if the first process sends the string Hello, the second process will send back the string olleH. (We have not covered strings, i.e., character arrays, in our C lectures yet, but there are several examples of reversing a C string in the following web page: https://www.programmingsimplified.com/c-program-reverse-string). The first process should print whatever it received from the second process to the console. This process should continue until the user types -1 to indicate that the operation is over. Your processes should exit gracefully, meaning that the second process should exit first, and the first process should wait for the second one to finish before it exits/returns itself. Your program will require using two pipes, one for sending the original message from the first process to the second process, and the other for sending the modified message from the second to the first process. You can write this program using either UNIX/Linux or Windows pipes (Note that we did not cover process creation, and anonymous pipe operations for Windows during the class, but your textbook has examples on both. Alternatively, Windows users can use the Cygwin utility which you should have used for your second assignment to emulate a Linux like development environment for their Windows machines).
Q3) from assignment 3 Write an echo server which performs the same job as your echo process in Question 2 above using the Java networking API we covered in class (look at the Data client and server examples in your lecture slides). The server should wait for a client connection using the accept() method. When a client connection request is received, the server will loop, performing the following steps: - Read data from the socket into a buffer. - Write the contents of the buffer back to the client. The server should exit from the above-described loop only when it has determined that the client has closed the connection (i.e., the result of the read operation is NULL). The client process, similar to the first process in Question 2 above, continuously inputs a string from the user via the keyboard, sends the string to the server, and prints whatever it receives from the server to the console. This process should repeat until the user types -1, upon which the client closes the connection and exits. Different from the second process above in Question 2, the server need not exit but runs forever waiting for client requests.
The echo server you have written as part of the third assignment was a single-threaded server, meaning that it can serve only one client process at a time (Please refer to Assignment 3 Question 3). Enhance your single threaded echo server by multithreading so that it can handle more than one request at a time.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started