The joys and jilts of non-blocking sockets

Robert Amesz rcameszREMOVETHIS at dds.removethistoo.nl
Tue May 15 20:42:28 EDT 2001


Fredrik Lundh wrote:

> Robert Amesz wrote:
>> Perhaps I haven't made myself clear. The point I'm trying to make
>> is that I'm suprised that an exception is raised for a case which
>> is not exceptional at all.
> 
> If you read up on socket behaviour, you'll notice that that error
> means the connection couldn't be *immediately* established.  If
> that's an error or not depends on your application.

Hmmm, if connecting to 'localhost' isn't immediate, what is? Because 
that's how I tested it. (Not that I'd rely on connect() *not* 
connecting immediately, but on my Windows box it obviously doesn't.)


> And if you look in the Python docs, you'll notice that you can use
> "connect_ex" instead of "connect" if you don't want the exception.

/me looks in Python docs and gasps in suprise

Oh my, how could I have overlooked that? That's pretty useful, thanks.

/me studies timeoutsocket.py

Oh, dear, connect_ex() is nowhere to be found in there. Tim O'Malley 
isn't going to like this.


Robert Amesz





More information about the Python-list mailing list