This article demonstrates and shows How to set up a simple Chat Room server and allow multiple clients to connect to it using a client-side script. The code uses the concept of sockets and threading to make this chatroom.
Lets Understand in brief firstly what is Sockets and Multi-Threading in python programming
Socket programming : Socket Programming in Python Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket (node) listens on a particular port at an IP, while other socket reaches out to the other to form a connection. Server forms the listener socket while client reaches out to the server.
MULTI-THREADING : So, every time a user connects to the server, a separate thread is created for that user and communication from server to client takes place along individual threads based on socket objects created for the sake of identity of each client.
We will require two scripts to establish this chat room. One to keep the serving running, and another that every client should run in order to connect to the server.
_Don’t worry if the above terms are complicated let’s understand _them in simple terms below:
Socket programming : They are just two end points act as communication channel between server and one or more client
MULTI-THREADING: A thread is a sub-process that runs a set of commands individually of any other thread.
#python #socket