Net-informations.com
SiteMap  | About    

Multithreaded socket server in Python

Multithreading Concepts

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:

  1. Python Multi Threaded Server Socket Program (Server.py)
  2. Python Client Socket Program (client.py)
Multithreaded Server Socket Example (Server.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.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.