TCP-Chat-Server is a simple chat server built using the TCP protocol that allows multiple clients to connect and communicate with each other. This project is designed to consolidate knowledge of network programming and concurrency by implementing a chat system.
- Multi-client communication: Allows multiple clients to connect and communicate concurrently.
- Broadcast messaging: Messages from any client are broadcasted to all connected clients.
- User commands:
/list
: List all connected clients./whisper [@username] [message]
: Send a private message to a specific user./name [@new_name]
: Change your displayed username./help
: View all available commands.
- Graceful exit: Support for the
/quit
command to exit the chat.
- Mastery of network programming with TCP.
- Use of concurrency to handle multiple clients simultaneously.
- Blocking I/O management.
- Building and packaging software with Maven.
-
Server Program:
- Accepts multiple client connections concurrently.
- Broadcasts received messages to all connected clients.
- Supports the
/quit
command for clients to leave the chat. - Supports the private message command , /whisper , between clients.
-
Client Program:
- Connects to the server.
- Allows setting a username upon entry.
- Sends and receives messages to/from the server.
- Receives all messages from all clients;
- Receive Private Messages from a specific client;
The usage of encapsulation and thread management where the main challenges tackled during this project. This one of the projects done during my Java learning process. It was great to accomplish this during the course, and with so compreensive code to mantain, for sure is not perfect, but still it's a journey. Exception handling, ArrayList<> and Thread synchronisation were two the most important parts of this code. The result is simple but the time spent during this exercise was well spent.
- Strenghen my knowledge on TCP communication and the usage of Streams both BufferedStreamReader and BufferedStreamWriter.
- The use of OOP Encapsulation concepts, my capacity of doing it improved a lot compared with previous projects.
- Code readability enhanced with the first point used.
- Thread synchronization for the List collection where we gather all clients and mantain the unique list to proper clients management add, remove and list.
- On this project you can find two folders ( tcp-chat-server and tcp-chat-client).
- Clone this repo by using git clone
- And open each of them separately on the IntelliJ.
- And don't forget have fun!