asyncore/asynchat do not notify connection errors on Wintel?

Z. Kotzer znewsgrp at
Wed Mar 15 16:01:26 CET 2006

I can not get error notifications when an asynchat based client tries to 
connect to a non-responsive address.

To validate the problem I changed lib/test/ as follows:

class echo_client(asynchat.async_chat):
    def __init__(self):
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect(('', PORT)) # <<<<<<<< Instead of HOST - set 
an address that does not listen to this port
        self.buffer = ""

    # <<<<<<<<<<<<<<< And added an error handler
    def handle_error(self):
        print 'ERROR'

Running it prints nothing - handle_error is not called and nothing is raised 
from asyncore.loop().

Debugging it shows that asyncore.connect gets EWOULDBLOCK and returns 
normally (as may be expected), select in asyncore.poll returns nothing 
(including empty e) and the socket remains forever.

Anybody has an experience with this behaviour?

Thanks in advance! 

More information about the Python-list mailing list