A real-time chat application built using Java Sockets. This project features a client-server architecture capable of handling multiple simultaneous users with private messaging, blocking capabilities, and colored terminal UI.
- Multi-Client Support: Handle many users at once using a thread-per-client model.
- Private Messaging: Send direct messages to specific users.
- User Blocking: Feature to ignore messages from specific participants.
- File Transfer Basic functionality of sending files to server.
- Networking: TCP/IP Sockets, Input/Output Streams, and Port Binding.
- Concurrency: Multi-threading (
Runnable),volatilevariables. - Synchronization: Thread-safe collections (
SynchronizedSet) andsynchronizedblocks for race-condition prevention. - Protocol Design: Custom command parsing and state management.
| Command | Action |
|---|---|
/list |
Show all online users |
/msg <user> <text> |
Send a private message |
/msgall <text> |
Broadcast message to everyone |
/block <user> |
Ignore a specific user |
/unblock <user> |
Resume seeing messages from a user |
/help |
Show command menu |
/exit |
Safely disconnect from server |
@ <filename> |
Sends and store files in server directory |
-
Compile the files:
javac *.java -
Run the server:
java ChatServer <port_no>
-
Run the clients in seperate terminals:
java ChatClient localhost <port_no>