Algorithm Steps:
Server:
Step 1: Start the program
Step 2: Create a socket with address family AF_INET type SOCK_STREAM and default protocol.
Step 3: Initialize a socket and set its attributes.
Step 4: Bind the server to the socket using bind function.
Step 5: wait for the client request, on request establish a connection using accept function.
Step 6: fork a child process, perform step 7-10 for each process.
Step 7: Read the message from the client thro the connection.
Step 8: Display the client I message.
Step 9: send an acknowledgement message to the client .
Step 10: Exit the child process.
Step 11: close the connection and go to step 5.
Client:
Step 1: start.
Step 2: create a socket with address family.
Step 3: Initialize the socket and set its attributes set the required port no.
Step 4: Type AF_INET socket with default protocol.
Step 5: Connect to server using connect function to initiate the request.
Step 6: Receive the acknowledgement from the server.
Step 7: stop.
CPP Program For Simple Message Passing:
|