Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions

Question

2. How will the team select a leader?

Answered: 1 week ago