Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

CLI Chat Application

A simple command-line chat application built with Python using sockets and threading for real-time communication between a server and client.

Features

  • Real-time bidirectional communication
  • Support for multiple client connections
  • Clean exit mechanism with 'bye' command
  • Cross-platform compatibility (Windows/Unix)
  • Clear console interface
  • Graceful handling of unexpected disconnections

Prerequisites

  • Python 3.x

Installation

  1. Clone the repository:
git clone https://github.com/CollinsKipkemoi/CLI-Chat-Application.git
cd CLI-Chat-Application

Usage

  1. Start the server:
python server.py
  1. Start the client in a different terminal:
python client.py
  1. Start chatting:
  • Type your message and press Enter to send
  • Type 'bye' to exit the chat
  • The server can shut down all connections by typing 'bye'

How It Works

Server (server.py)

  • Listens on port 5000
  • Handles multiple client connections using select
  • Broadcasts messages to connected clients
  • Manages client disconnections gracefully

Client (client.py)

  • Connects to the server on localhost:5000
  • Uses threading for simultaneous message sending and receiving
  • Provides a clean console interface
  • Handles server disconnection gracefully

Commands

  • bye: Exit the chat (works for both client and server)
  • Server's 'bye': Shuts down the server and disconnects all clients
  • Client's 'bye': Disconnects the client while keeping the server running

Error Handling

  • Handles unexpected client disconnections
  • Manages server shutdown gracefully
  • Cleans up resources properly
  • Clear error messages for common issues

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

About

Python-based command-line tool that enables real-time bidirectional communication between multiple clients and a server using sockets and threading.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages