Max00355
Max00355

Reputation: 867

Multiple Connections to a Socket Without Threading or Spawning a New Process With Python

Is it possible to write a server that allows multiple connections without using threads or a new process?

Now I am not talking about a bunch of socket.accepts(), but is there a different way?

Upvotes: 0

Views: 831

Answers (2)

mhawke
mhawke

Reputation: 87084

Python provides the module asyncore. Here is a nice example of an echo server.

Upvotes: 2

msw
msw

Reputation: 43497

If you don't have multiple accepts you don't have multiple connections so it doesn't matter how you process things that aren't there.

It is possible to handle multiple accepted connections in a single thread using a classical select loop.

Upvotes: 3

Related Questions