Skip to content Skip to sidebar Skip to footer

How To Multiplie Clients

This is a part from a code that make connection between server to client. i want to multiplie the client. appriciate help. import socket, pickle import threading BUF_SIZE = 8192

Solution 1:

The common practice is to start a new thread or process for each connected client like (I do not know Python so I will explain it in some pseudocode):

create server socket;
listen on specific address;

while (true)
{
     accept client;
     start a new thread for client;
}

close server socket;

In new thread you will process every new client connection, need only client socket to pass to the new thead.

new thread function (client socket)
{
     read (client socket);
     write (client socket);
     close (client socket);
}

I also recomend you to increase listen backlog queue to 2-5 connections.

Post a Comment for "How To Multiplie Clients"