Multithreaded socket server in Python
A thread is a sequence of such instructions within a program that can be executed independently of other code. A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution. Multithreaded Socket Programming describes that a Multithreaded Socket Server can communicate with more than one client at the same time in the same network.
In the previous lesson Python Socket Programming describes a Server Socket Program can communicate with only one client at a time . That means, the Python Server Socket Program does not accept more than one Client connection . From the following section you can understand how to a Python Multithreaded Server M can communicate with more than one Clients at the same time . You can see the basics of Socket Programming in the previous lesson , before you start this section take a look at Python Socket Programming
Python Multithreaded Socket Programming has two sections:
- Python Multi Threaded Server Socket Program (Server.py)
- Python Client Socket Program (client.py)
Python Socket Client Example(client.py)
How to run this program ?
Create Python Multi Threaded Server Socket Program (Server.py) and Python Client Socket Program (client.py) in two separate files. Open a DOS prompt (console) and run the Server Program first. Then you will get the message "Server started" in Server side. Next you start the Client program in another DOS prompt (console), then you can see the message from Server . Like this , you can start more than one client at the same time from different Dos prompts and communicate with the Server program. The server accept your message and reply the same message to the same client. You can open many client program and test the server reply to each client.
- How to find hostname of a computer - Python
- How To Find IP Address In Python
- Send mail from Gmail account using Python
- Retrieving Email from a POP3 Server - Python
- Retrieving Web Pages with HTTP using Python
- How to open a web browser using Python
- Creating an FTP client in Python
- Socket Programming in Python