Lab Workout 1 1. Write a simple TCP iterative server and client program that performs the following functionality: The client asks the user to enter a sentence (whose maximum size is known) from the keyboard. It then sends the sentence to the server, which calculates the number of words (separated by one or more spaces) in the sentence and the answer is sent back to the client, which then prints the result. 2. Write a simple TCP concurrent server and client program that performs the following functionality: The client asks the user to enter a sentence (this time the maximum size is not known) from the keyboard. The client sends the sentence to the server. The client might need to send it in multiple parts, and only after the entire sentence has been received by the server, it sends back the number of words in the sentence to the client. The client then prints the result. 3. Write a simple UDP server and client program that performs the following functionality: You are given two directories ‘questions’ and ‘answers’, which contains 100 files each, ‘1.txt’ to ‘100.txt’ where each file correspond to a question and answer in the corresponding directories. The client program asks a question from a random file in ‘questions’ directory to the user, gets the user’s input as one of the four options (1/2/3/4) and sends the question number along with the answer to the server. The server evaluates the user’s input and then sends back whether the user has given correct answer or not to the client. The client displays the server’s response to the user. The client has access to questions directory only and the server has access to answers directory only.
© Copyright 2024 ExpyDoc