Uploaded by Ahmed El Ashmawy

3313 project

advertisement
Overview:
3313Chat is a chatting application that allows clients to connect to chatrooms created by the
server to chat with other clients. They can connect and disconnect when they would like. There
are 2 main components to this application. As mentioned there will be a client side and a server
side. The server will be the one to dictate how many chatrooms are made as well as when the
chatrooms are open and closed.
How many threads are needed?
Each chatroom can allow an infinite amount of threads. A thread would be created for each
client that would be connected to it. A singular thread would be created for the main server
application which would hold all the client threads. The server thread would direct all the traffic
to the messages-specific chatroom.
What sort of synchronization objects will be used?
To maintain synchronization in the chat system, the server thread updates the message board
for each chat room, and users only see messages sent in their respective chat rooms. The
server achieves this by checking and updating the chat room associated with each client's
socket thread. To ensure continued synchronization, message boards are cleared when users
switch chat rooms.
In addition, semaphores are used as a synchronization object to protect active session
information. Vectors map client threads, and semaphores ensure that only one vector is
accessed at a time, thus preventing conflicts and ensuring proper synchronization.
How will you handle termination?
To terminate the server gracefully the destructors would be called upon for each thread. The
action of termination would be handled on the server side by typing “done” into its’ console. This
would then call upon the destructors to destroy all the threads. On the client side GUI, there
would be a button called “Leave Chatroom” disconnecting itself from the server and notifying the
server to destroy that thread.
Download