Question: In this assignment you will learn and practice socket programming. You will use socket programming and threads in C. You will write one server program,

In this assignment you will learn and practice socket programming. You will use socket programming and threads in C. You will write one server program, and one client program:

Server: The server program should maintain an account balance, with the initial value to be 100. Then, it will create a socket and start listen deposit or withdraw requests from client programs. For each deposit/withdraw request, you should create a new thread to process such the request. The server program should deploy appropirate synchronization mechanism to protect the integrity of the account balance.

Client: The client program will act as agents to send out reqeusts for deposit or withdraw from the account balance to the server program. In addition to the server IP and port number, the client program should take four (4) additional paramters to perform randomly deposit/withdraw like follows:

> client serverIP serverPort action-code num-ops min max serverIP/serverPort: the IP and port nubmer of server program; action-code can be 0 or 1, where 0 is deposit, and 1 for withdraw. num-ops indicates number of specified operations; min/max indicate the range [min, max] for the amount of each deposit/withdraw operation;

You need to figure out how to implement both server and client programs in C, where the server proram has to be implemented with Pthreads to handle each new request. You need to be carefull about how to synchronize the actions of the threads when modifying the account balance based on the request by adopting appropriate semaphore or mutex; You should be able to start client programs multiple times concurrently!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!