Implement a TCP client- server application to implement a service that returns the sounds made by animals. The name of each requested animal will be specified by a client . The server will start in passive mode listening on a specified port for a transmission from a client. Separately, the client will be started and will contact the server on a given IP address and port number that must be entered via the command line.
If the server is subsequently restarted, it reverts to knowing only about the initial 3 pairs.
- Return the sound made by animals named by a client after the client connects to the server using the SOUND instruction,
- Accepts a STORE message used for storing new (animal, sound) pairs,
- Accepts a QUERY message used to ask which animals it knows,
- Accepts a BYE message that results in closing of the current session between the client and the server.
- Accepts an END message that results in closing of the current session and termination of the server.
- register - To register with server
- login - To communicate with server (if client is already registered)
- sound - To confirm that connection has established
- store - To store new animal-voice pair
- query - To get names of all stored animals
- bye - To instruct server that client no longer needs this session
- end - To instruct server to shut down
- animal name - To get voice of given animal
Client: SOUND
Server: SOUND: OK
Client: DOG
Server: A DOG SAYS WOOF
Client: CAT
Server: I DON’T KNOW CAT
Client: STORE
CAT
MEOW
SERVER: STORE: OK
Client: QUERY
SERVER: DOG
HORSE
SNAKE
COW
SHEEP
CAT
QUERY: OK
Client: BYE
SERVER: BYE: OK
Client: END
Server: END: OK