Question: What is a socket? Explain in detail how two processes communicate using SOCK _ STREAM. Illustrate your explanations by a simple server - client program
What is a socket? Explain in detail how two processes communicate using
SOCKSTREAM. Illustrate your explanations by a simple serverclient program
that operates as follows:
A client sends to the server a message including their name and an integer
number in the range to egJohn The name in this case
John is the first argument of the client program. The IP address of the
server is the second argument. The number is the third argument.
The server first randomly generates an integer number in the range to
and then waits for messages from clients.
On receipt of a next message the server extracts the name of the client from
the message, compares the number sent in the message with the locally
generated number, and responds to the client with a message containing the
clients name, of the form Sorry John, you did not win. if the numbers are
different, or Congratulations John! You are a lucky winner. otherwise.
The client receives the message from the server and prints it on the screen.
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
