confusion and problems with first socket script

Andrew Bennetts andrew-pythonlist at puzzling.org
Thu Feb 19 02:51:38 EST 2004


On Wed, Feb 18, 2004 at 11:06:11PM -0800, Hameed Khan wrote:
[...]
> 
> as you can see two connections have been made at one
> after another. and i have specify 1 in listen()
> argument then why two clients can connect to it. i am

Actually, the argument to listen only specifies the number of *queued*
connections, i.e. how many connections can be waiting for a call to accept.

If you want to restrict the number of connections, you need to do this
yourself by accepting then immediately closing any unwanted connections.
(Some protocols specify a way for the server to send a simple "Too many
connections, try later" message before doing this)

-Andrew.





More information about the Python-list mailing list