Skip to content
Snippets Groups Projects

Bavlsik Homework 2


Description

Modification of TcpExample3 and adding some code to implement a passcode protected chat room with multiple clients.

The 'BavlsikServer' class sets up a server that listens for incoming client connections on port 2317. When a client connects, the server creates a new handler thread for managing communication with that client. After the connection is established, the server prompts the client for a passcode. If the client enters a valid passcode they are added to teh chat room where each client's messages are broadcast to all other connected clients. If the passcode is entered incorrectly, they client is disconnected from the server. If a client enters 'quit' they disconnect from the server.

The 'BavlsikClient' class connects to a server running on localhost at port 2317. If the client enters a correct passcode, they are added to the chatroom, if it is incorrect they are disconnecte. The client then sends user input from the console to the server and displays messages received from the server.