In this project, you are required to do socket programming in C language (Linux environment) to implement a pair of client and server that can achieve simple password verification to indicate the current market value of the stock. Your client will send a pair of username and password to your server and your server will verify whether the pair of username and password is legitimate or not for retrieving the stock value. Assume the only legitimate pairs of usernames and passwords that will be accepted by your server are as follows. Username Password StockValue lcid welpa23e 13.93 mrvl ghqwo31a 41.23 snap tyjli14d 10.21 cl1 rjwqe83f 85.09 bro gnmds28z 56.43 cvs rhktl87c 91.34
In this project, you are required to do socket
Username | Password | StockValue |
lcid | welpa23e | 13.93 |
mrvl | ghqwo31a | 41.23 |
snap | tyjli14d | 10.21 |
cl1 | rjwqe83f | 85.09 |
bro | gnmds28z | 56.43 |
cvs | rhktl87c | 91.34 |
StockFile.txt
Specifically, your client and server programs entail to achieve the following requirements:
1. Your client program needs to take two arguments that specify the name of server and the port that it is trying to connect to. Your program for server needs to take an argument that specifies the port that it is listening to. You can use (5000+last 4 digits of your student-id number) as a port number.
2. The server program will start first and keep listening to the specified port. Your client will connect to the port that your server is listening to, and a socket between your client and server is constructed.
3. Your client program will first prompt a welcome message that asks the user to enter a username using the keyboard. This username will then be sent to the server. Then, your server, after receiving the username from your client, will send an acknowledgment message to the client.
4. Your client, after receiving the acknowledgment message from your server, will prompt a message that asks the user to enter the corresponding password. This password will then be sent to the server. Then, your server, after receiving the password from your client, will verify the received pair of username and password against the list of legitimate pairs. If the result is positive, the server will send a success message along with the current market value of the stock to the client. If the result is negative, the server will send a failure message to the client.
5. Your client, after receiving the result message, will print out the result and close the socket. Your server will close the socket following the client, and keep listening for the next client request.
6. Your server will close the socket after waiting for the username or the password for 30 seconds.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps