Simple Chat room using Python

Published on . Written by

Simple Chatroom using Python
This python project is straightforward and simple to make and would consummately function as a scaled-down venture or for self-learning purposes. To begin you just to get familiar with Socket Programming and Some python concept. Here we are going to build a Simple Chat Room Server and enable different individuals to interface and speak with each other. The concept used here is socket programming and threading.

Read more..
Project Description


Skyfi Labs Projects
Socket Programming: Sockets refer to endpoints in any communication channel and these are utilized for interfacing Server and Client. Sockets are bi-directional, which implies it builds up communication between a server and one or more clients.

Here in this python project, we are going to set up sockets for each end and set up the chatroom framework among various clients through the server. Socket present on the server-side partners itself with some hardware port present on the server-side. Any client that has a socket associated with a similar port and need to speak with the server attachment can do it effectively.

Client-Side and Server-Side Script: The client-side script will attempt to get to the server socket created at the specified IP address and port. Once the connection is done, it will consistently check whether input originates from the server or from the client, and accordingly redirects output.

  • If the input is from the server-end, it shows the message on the terminal end.
  • If the input is from the client-end it will, sends the message that the client enters the server.
The server-side script will attempt to build up a socket and bind it to an IP address and port indicated by the client-end. This script will remain open and get connection requests and will add the respective socket objects to a list and to keep track of active connections. Each time a client connects, a separate thread will be created for that user and each thread that is created, the server awaits a message and sends that message to different clients as of now on the chatroom. If the server confronts any error while trying to receive a message from a particular thread, it will directly stop the thread and exit.

Multithreading or Threading: A thread is a small sub-process that runs a set of directions individually of any other thread. So, every time when a user wants to communicate with the server, “a separate thread is created” for that client and communication from server to client happens along individual threads based on socket objects created for the well-being of identity of every client.

We will need two scripts to create this chat room. The first one to keep the server running, and second for every client must be in order to connect with the server.

Python: For programming purposes, we are going to use Python as the Programming language. Python is simple to learn and chip away at with language. It is a high-level, general-purpose programming and highly interrupted language.

Project Implementation:

1. Firstly we need to set up communication among servers and this can be done using a local area network (LAN) by picking any PC to be a server hub, and utilizing that PC's private IP address as the server IP address.

For instance, if a LAN has a lot of private IP addresses with itself ranging from 192.252.0.0 to 192.252.0.99, at that point any PC from these 100 hubs can go about as a server, and the rest of the hubs may connect to the server hub by using the server’s private IP address. We should pick a port that is as of now not being used in any case.

2. If the server is intended to be reachable ahead of the nearby system, at that point the open IP address would be prescribed to utilize.

3. Presently the subsequent stage is PC association and if computers are connected via LAN, then we can use IP addresses to communicate.

4. Now this server will show its IP address and request a name for the server. From the client-side, we need to make reference to a name and also the IP address of the server to connect.

5. Communication is done and now we can chat in the chatroom.

Software Requirement:

Programming language - Python

Operating System - Windows, ubuntu.

Kit required to develop Simple Chat room using Python:
Technologies you will learn by working on Simple Chat room using Python:


Any Questions?


Subscribe for more project ideas