In this assignment, you will write two complete C programs to support a client/server model using Linux sockets. In particular, Server X is creating a Ponzi scheme where he has created a finite amount of 30 crypto currency units (similar to Bitcoin, Ethereum, Litecoin, etc.) whereby he is looking for investors to purchase his crypto currency for anywhere between $3,000 and $5,000, inclusively, depending on the current market price. Your program will develop a two-tiered purchasing system that will consist of a distributor (i.e., the server) that will provide services to "BUY" and SELL the crypto currency to two investors (i.e., the clients) as follows:
Server
Clients (note that there are 2 clients, but 1 client source code)
Your program should run on the INET domain using SOCK_STREAM (i.e., TCP) sockets so that the server and each of the two clients execute on three different CSE machines at the same time. The server code will accept the port number to communicate on as an argument to the program, while the client code (again, two clients using the same code) will accept the hostname of the server and the agreed- upon port number to communicate on as arguments to the program.
Instructor's Note: After the SEC determined this was a Ponzi scheme, the agency issued a cease and desist order and all money invested was lost. This assignment is not based on actual events and any resemblance to such is purely coincidental.
SAMPLE OUTPUT (user input shown in bold green):
==> SERVER on cse04
Chriss120299@cosc04:~$ ./minor6svr usage: ./minor6svr port Chriss120299@cosc04:~ $ ./minor6svr 11800
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$4012.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY
$4337.00
[CLIENT 1]: BUY
[SERVER
[CLIENT [SERVER X]:
2]:
X]: Client BUY
Client 1
2 BUY
BUY $4846.00
$4973.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$4058.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY
$3336.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$3045.00
[CLIENT 2]: BUY
[SERVER [CLIENT
[SERVER X]:
1]:
X]: Client BUY
Client 2
1 BUY
BUY $3058.00
$4603.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY
$4856.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$3755.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY
$3207.00
[CLIENT 1]: BUY
[SERVER [CLIENT
[SERVER X]:
2]:
X]: Client BUY
Client 1
2 BUY
BUY $3058.00
$3404.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$3990.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY
$4197.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$3241.00
[CLIENT 2]: BUY
[SERVER [CLIENT
[SERVER X]:
1]:
X]: Client BUY
Client 2
1 BUY
BUY $4658.00
$4152.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY
$4741.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY
$3952.00
[CLIENT 2]: SELL
[SERVER X]: Client 2 SELL $3090.00 [CLIENT 1]: SELL
[SERVER X]: Client 1 SELL $4327.00 [CLIENT 2]: BUY
[SERVER X]: Client 2 BUY $4895.00 [CLIENT 1]: BUY
[SERVER X]: Client 1 BUY $3995.00
[CLIENT
[SERVER 2]:
X]: SELL
Client
2
SELL $4834.00
[CLIENT 1]: SELL
[SERVER
[CLIENT [SERVER X]:
2]:
X]: Client BUY
Client 1
2 SELL $4473.00
BUY $3680.00
[CLIENT
[SERVER 1]:
X]: BUY
Client
1
BUY $3531.00
[CLIENT
[SERVER 2]:
X]: SELL
Client
2
SELL $4261.00
[CLIENT
[SERVER 1]:
X]: SELL
Client
1
SELL $3746.00
[CLIENT 2]: BUY
[SERVER [CLIENT
[SERVER X]:
1]:
X]: Client BUY
Client 2
1 BUY $4543.00
BUY $3154.00
[CLIENT
[SERVER 2]:
X]: SELL
Client
2
SELL $3591.00
[CLIENT
[SERVER 1]:
X]: SELL
Client
1
SELL $4072.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY $3770.00
[CLIENT 1]: BUY
[SERVER [CLIENT
[SERVER X]:
2]:
X]: Client SELL
Client 1
2 BUY $3485.00
SELL $3674.00
[CLIENT
[SERVER 1]:
X]: SELL
Client
1
SELL $3828.00
[CLIENT
[SERVER 2]:
X]: BUY
Client
2
BUY $3087.00
[SERVER X]: CRYPTO 10 units BALANCE: $77723.00
==> SAMPLE: CLIENT 1 on cse05
Chriss120299@cosc04:~$ ./minor6cli
usage ./minor6cli hostname port Chriss120299@cosc04:~$ ./minor6cli cse04 11800
[CLIENT]:
[CLIENT]:
[SERVER]: BALANCE = BUY
BUY PRICE $40000
$4012.00
[CLIENT]:
[CLIENT]: BALANCE =
BUY $35988
[SERVER]: BUY PRICE $4846.00
[CLIENT]:
[CLIENT]:
[SERVER]: BALANCE = BUY
BUY PRICE $31142
$4058.00
[CLIENT]: BALANCE = $27084
[CLIENT]:
[SERVER]: BUY
BUY PRICE
$3045.00
[CLIENT]:
[CLIENT]:
[SERVER]: BALANCE = BUY
BUY PRICE $24039
$4603.00
[CLIENT]:
[CLIENT]:
[SERVER]: BALANCE = BUY
BUY PRICE $19436
$3755.00
[CLIENT]: BALANCE = $15681 [CLIENT]: BUY
[SERVER]: BUY PRICE $3058.00 [CLIENT]: BALANCE = $12623 [CLIENT]: BUY
[SERVER]: BUY PRICE $3990.00 [CLIENT]: BALANCE = $8633 [CLIENT]: BUY
[SERVER]: BUY PRICE $3241.00 [CLIENT]: BALANCE = $5392 [CLIENT]: BUY
[SERVER]: BUY PRICE $4152.00 [CLIENT]: BALANCE = $1240 [CLIENT]: BUY
[SERVER]: BUY PRICE $3952.00 [CLIENT]: BALANCE = -$2712 [CLIENT]: SELL
[SERVER]: SELL PRICE $4327.00 [CLIENT]: BALANCE = $1615 [CLIENT]: BUY
[SERVER]: BUY PRICE $3995.00 [CLIENT]: BALANCE = -$2380 [CLIENT]: SELL
[SERVER]: SELL PRICE $4473.00 [CLIENT]: BALANCE = $2093 [CLIENT]: BUY
[SERVER]: BUY PRICE $3531.00 [CLIENT]: BALANCE = -$1438 [CLIENT]: SELL
[SERVER]: SELL PRICE $3746.00 [CLIENT]: BALANCE = $2308 [CLIENT]: BUY
[SERVER]: BUY PRICE $3154.00 [CLIENT]: BALANCE = -$846 [CLIENT]: SELL
[SERVER]: SELL PRICE $4072.00 [CLIENT]: BALANCE = $3226 [CLIENT]: BUY
[SERVER]: BUY PRICE $3485.00 [CLIENT]: BALANCE = -$259 [CLIENT]: SELL
[SERVER]: SELL PRICE $3828.00
[CLIENT]: CRYPTO 10 units BALANCE: $3569.00
==> SAMPLE: CLIENT 2 on cse06
Chriss120299@cosc04:~$ ./minor6cli cse04 11800
[CLIENT]: BALANCE =
[CLIENT]: BUY $40000
[SERVER]: BUY PRICE $4337.00
[CLIENT]: BALANCE = $35663
[CLIENT]: BUY
[SERVER]: BUY PRICE
$4973.00
[CLIENT]: BALANCE = $30690
[CLIENT]: BUY
[SERVER]: BUY PRICE $3336.00 [CLIENT]: BALANCE = $27354 [CLIENT]: BUY
[SERVER]: BUY PRICE $3058.00 [CLIENT]: BALANCE = $24296 [CLIENT]: BUY
[SERVER]: BUY PRICE $4856.00 [CLIENT]: BALANCE = $19440 [CLIENT]: BUY
[SERVER]: BUY PRICE $3207.00 [CLIENT]: BALANCE = $16233 [CLIENT]: BUY
[SERVER]: BUY PRICE $3404.00 [CLIENT]: BALANCE = $12829 [CLIENT]: BUY
[SERVER]: BUY PRICE $4197.00 [CLIENT]: BALANCE = $8632 [CLIENT]: BUY
[SERVER]: BUY PRICE $4658.00 [CLIENT]: BALANCE = $3974 [CLIENT]: BUY
[SERVER]: BUY PRICE $4741.00 [CLIENT]: BALANCE = -$767 [CLIENT]: SELL
[SERVER]: SELL PRICE $3090.00 [CLIENT]: BALANCE = $2323 [CLIENT]: BUY
[SERVER]: BUY PRICE $4895.00 [CLIENT]: BALANCE = -$2572 [CLIENT]: SELL
[SERVER]: SELL PRICE $4834.00 [CLIENT]: BALANCE = $2262 [CLIENT]: BUY
[SERVER]: BUY PRICE $3680.00 [CLIENT]: BALANCE = -$1418 [CLIENT]: SELL
[SERVER]: SELL PRICE $4261.00 [CLIENT]: BALANCE = $2843 [CLIENT]: BUY
[SERVER]: BUY PRICE $4543.00 [CLIENT]: BALANCE = -$1700 [CLIENT]: SELL
[SERVER]: SELL PRICE $3591.00 [CLIENT]: BALANCE = $1891 [CLIENT]: BUY
[SERVER]: BUY PRICE $3770.00 [CLIENT]: BALANCE = -$1879 [CLIENT]: SELL
[SERVER]: SELL PRICE $3674.00 [CLIENT]: BALANCE = $1795 [CLIENT]: BUY
[SERVER]: BUY PRICE $3087.00
[CLIENT]: CRYPTO 10 units BALANCE: -$1292.00