Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

💬 Simple Chat Application

A simple, easy-to-use chat application built with Python sockets. Multiple clients can connect to a central server and chat with each other in real-time.

🚀 Features

  • Real-time messaging - Instant message delivery
  • Multiple clients - Support for unlimited users
  • User-friendly interface - Clean and simple UI
  • Username system - Each user has a unique username
  • Join/Leave notifications - See when users join or leave
  • Timestamp messages - All messages show time
  • Easy to use - Simple setup and operation

📁 Project Structure

SimpleChatApp/
├── server.py      # Chat server
├── client.py      # Chat client
└── README.md      # This file

🛠️ Requirements

  • Python 3.6 or higher
  • No additional libraries required (uses only built-in modules)

🚀 How to Run

Step 1: Start the Server

Open a terminal/command prompt and run:

python server.py

You should see:

==================================================
💬 Simple Chat Server
==================================================
🚀 Chat Server started on 0.0.0.0:5555
Waiting for clients to connect...

Step 2: Start Clients

Open new terminal windows for each client and run:

python client.py

For each client:

  1. Enter server IP (default: 127.0.0.1)
  2. Enter server port (default: 5555)
  3. Enter your username
  4. Start chatting!

💡 Usage

Server Commands

  • Start server: python server.py
  • Stop server: Press Ctrl+C

Client Commands

  • Start client: python client.py
  • Send message: Just type and press Enter
  • Quit chat: Type quit or press Ctrl+C

🎯 Example Session

Server Output:

🚀 Chat Server started on 0.0.0.0:5555
Waiting for clients to connect...
📱 New connection from ('127.0.0.1', 12345)
👤 Alice joined the chat
📱 New connection from ('127.0.0.1', 12346)
👤 Bob joined the chat
💬 Alice: Hello everyone!
💬 Bob: Hi Alice!
👋 Alice left the chat

Client Output:

==================================================
💬 Simple Chat Client
==================================================
Enter server details:
🌐 Server IP (default: 127.0.0.1): 
🔌 Server Port (default: 5555): 
✅ Connected to server at 127.0.0.1:5555
👤 Enter your username: Alice

🎉 Welcome, Alice!
💡 Type your messages below. Type 'quit' to exit.
--------------------------------------------------

🔔 Welcome to the chat, Alice! Type your messages below.

[14:30:15] You: Hello everyone!

[14:30:20] Bob: Hi Alice!

[14:30:25] You: 

🔧 Customization

Change Server Port

Edit server.py line 8:

def __init__(self, host='0.0.0.0', port=5555):  # Change 5555 to your preferred port

Change Server IP

Edit server.py line 8:

def __init__(self, host='0.0.0.0', port=5555):  # Change '0.0.0.0' to your IP

🌐 Network Usage

  • Local network: Use your computer's IP address (e.g., 192.168.1.100)
  • Internet: Requires port forwarding on your router
  • Firewall: Make sure port 5555 is allowed

🐛 Troubleshooting

"Connection refused" error

  • Make sure the server is running
  • Check if the IP and port are correct
  • Verify firewall settings

"Address already in use" error

  • Wait a few seconds and try again
  • Or change the port number in server.py

Messages not appearing

  • Check your internet connection
  • Make sure you're connected to the right server
  • Try restarting the client

📝 Technical Details

  • Protocol: TCP sockets
  • Encoding: UTF-8
  • Message format: JSON for structured messages
  • Threading: Multi-threaded server for handling multiple clients
  • Error handling: Graceful disconnection and reconnection

🤝 Contributing

Feel free to improve this project by:

  • Adding new features
  • Fixing bugs
  • Improving the UI
  • Adding encryption
  • Adding file sharing

📄 License

This project is open source and available under the MIT License.


Happy Chatting! 🎉

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages