Question: You are to write two programs: 1 . A client program that will connect with your server and ask for the public key of a
You are to write two programs: A client program that will connect with your server and ask for the public key of a given user A server program that will read a list of pairs userID public key from a file, wait for connection requests from client processes, and send them back either a string containing the requested public key or a code notifying them that the user is not in the database.THE SERVER PROGRAMYour server should start by prompting the user for a filename:Enter a file name: keystxtThis file will contain pairs of user IDs and public keys as n:jorge@uh edualbcdfabceva@rice.edu cdfabcBoth entries will never contain any white spaces. It will then store the contents of the file into a table. Your server should then prompt for a port number as in:Enter the server port number: It will then: Create a datagram socket in the Internet domain, Do a bindto bind the socket to the specified port number Enter an infinite loop where it will repeatedly do a recvfrom to receive user IDs from its clients then a sendto to reply with the corresponding public keys.shoud print out ine user B it ree esand its Ma arverjorge@uh edu: Found a public key rick@tamu.edu: Not in the databaseYour server will keep accepting client requests until it receives a Done message from one of its clients. In that case, it should terminate after printing:Terminated by user request.THE CLIENT PROGRAMYour client should start by prompting the user for a server hostname and a server port number as:Enter the server hostname: localhostEnter the server port number: It will then prompt for a user ID as:Enter a user ID: jorge@uh eduIt should then create a datagram socket, do a sendto to send the user ID to the server then a recvfrom to get its reply. Once this reply has arrived, the client should display the outcome of the query as:The public key for jorge@uhedu is albThe user rick@tamu.edu is not in the database.Unlike the server, each client will only handle a singlerequest
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
