Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task #1. First (1), create the Server (name it myServer1.c) program to accept one argument which is the port number of the server to bind

Task #1.

First (1), create the Server (name it myServer1.c) program to accept one argument which is the port number of the server to bind and listen to. Second (2), create the client program (name it myClient1.c) to accept two arguments (IP address and port number of the Server).

Task #2.

Copy the Task#1 programs and name the server "myServe2.c" and the client "myClient2.c" for Task #2.

When a client connects to the server, the server will create a thread to serve this client (for each command sent from the client to be processed in the server, and its result sent back to the client).

Notes:

A client will send a simple command via socket program to a server listening. The server will receive a command from the client, use a thread to handle this command to be processed, and then echo back its result of the command to the client. You need to set up a pipe for each thread to process the command to output its result through pipe, then to socket (back to the client).

For example, try first with ls command. That is, ls command is sent from the client, the server-thread receives it and process the ls command in the server, and then pipe its result to the socket so that the result is then sent back to the server.

Task #3.

Copy the Task#2 programs and name the server "myServe3.c" and the client "myClient3.c" for Task #3.

Modify the server so that the result of the command (e.g., ls or ls | sort) processed by each thread will be kept (logged) into a log file (file name: myLog.txt). That is, the result of each command is echoed back to the client as well as to be logged in the server's log file (to append the log to the log file).

Notes:

You may need to a mutex to lock the log file if you have more than one thread trying to access the log file exclusively.

You should name the source programs as follows: the name of the server program is: myServer2.c, and the client program is: myClient2.c.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

LO2 Explain the nature of the psychological contract.

Answered: 1 week ago

Question

LO1 Discuss four different views of motivation at work.

Answered: 1 week ago