A lightweight peer-to-peer (P2P) chat application designed for local area networks (LAN). This application enables real-time text communication between users connected to the same network, without requiring internet access or external servers.
- Username Registration: Users can set their username once, which is saved locally.
- Auto IP Discovery: Uses DISCOVER/RESPONSE packets to dynamically detect other active users on the network.
- Real-Time Chat: Supports sending and receiving messages in real time over TCP.
- Online User Tracking: Displays a list of currently online peers.
- Modular Architecture: Separate components for networking, message handling, and user interaction.
- College labs and classrooms
- Office environments
- Hostels and dormitories
- LAN parties and gaming
- Emergency or backup communication setups
- Temporary event setups (workshops, hackathons)
src/
├── ChatClient.java # Sends messages to other users
├── ChatServer.java # Listens for incoming messages
├── ClientHandler.java # Handles incoming TCP messages
├── CommandHandler.java # Parses and executes user commands
├── FriendManager.java # Manages DISCOVER/RESPONSE logic
├── UserManager.java # Manages username persistence
├── DiscoveryListener.java # Listens for DISCOVER packets
├── ResponseListener.java # Handles incoming RESPONSE packets
├── NetworkUtils.java # Fetches local IP
- On launch, the application prompts the user to set a username (stored locally).
- It then starts broadcasting a
DISCOVER
message over the LAN. - Other users respond with a
RESPONSE
, indicating their presence and details. - The list of online users is updated and maintained dynamically.
- Users can send messages using the console by selecting usernames from the online list.
- Messages are sent using TCP sockets and handled by the
ClientHandler
on the receiving end.
- Java 8 or higher
- A shared LAN environment (Wi-Fi or Ethernet)
- Clone the repository.
- Compile the Java source files:
javac *.java
- Run the application:
java Main
- Alias system for resolving conflicts between identical usernames.
- GUI support (e.g., Swing or JavaFX).
- File sharing and media support.
- Encryption for message security.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.,