If the room ID already exists, mainserver gets multicasting group address and port number of the existed chat room, and the IP and TCP port number of the subserver that has the chat room. Mainserver sends a message to the client, tells it the IP address and TCP port number of the subserver, and the multicasting group 224.0.dd.dd and port number. And joins the multicast group 224.0.dd.dd sent by mainserver. Any line typed by a user of chat is sent to its subserver where it is sent to all other group participants using multicasting. Every line is prefixed with the sender's user name.
Any line received by chat from subserver is displayed to the user.
Any user can leave the conversation at any time while all other participants may continue to chat. The TCP port number, multicasting group address and port number of each room. There are two kinds of client leaving, leaving gracefully and leaving abruptly. Client send a message to its subserver, telling it is going to leave. Subserver can detect the client leaving abruptly by the Java TCP connection exception.