In: Computer Science
1) Using algorithm or pseudocode, describe the implementation of the server side of a public chatroom application with the following specification:
Any client that wishes to join the chatroom, must send the message “Hello” to the server’s IP address at port 2020. After sending the “Hello” message, the client is admitted into the chatroom. While in the chatroom, any message sent by any client must be received by all other clients. Finally, when a client decides to leave the chatroom, it sends the “Bye” message to the server. After the server sees a “Bye” message from a client, it must stop sending any further message to that client.
What kind of socket should the server application use? Why?
Implementation of the server side of a public chatroom application
1) Define the server.
2) Define type of socket to read the address and data.
3) Read the IP Address and Port entered by client ( Make sure client is aware about the parameters).
4) Bind the server to mentioned IP Address and Port.
5) Check if the Address domain of the socket in the form of IP address is right.
6) Check if the type of socket is right.
7) Then bind the server to the IP address and Port and set the number of connections, in this case 'ALL'.
8) Print and inform all the connection on the server.
9) Broadcast a message as "Hello" to all the connection which are active but don't send to the users.
10) Connect to connection whose user object is 'Hello'.
11) If there is no Connection with " Hello" , then remove.
12) Else Accept the connection request - start thread.
13) Maintain the list of the connection.
14) Close the connection if message is "Bye" or lost connection abruptly.
15) Disconnect from the list of Socket.
16)Disconnect from the list of users.
Socket should be used in the server side are :
Address Domain Socket - Since the connection is set between
multiple host on internet so, they need to have a common
address.
Streaming Socket - To read theflow of data in the chatroom
continuously.