Async DNS?

Andrew Markebo andrew.markebo at telelogic.com
Mon Nov 6 07:48:04 EST 2000


Are you looking for a module that does DNS lookups, or you don't want
the sockets to block when you connect to an address??

Set the socket to nonblocking before you do the connect,
socket.setblocking(...)

self._sock.setblocking(0)
try:
    self._sock.connect((self._host, self._port))
except socket.error, why:
    try:
        (code, msg)=why
    except ValueError:
        code=0
    # I am not sure these are raised or not, but they are OK.. 
    if not code in (EINPROGRESS, EALREADY, EWOULDBLOCK):
        self.close()
        self.closed=1
        raise ERROR, why

        /A



More information about the Python-list mailing list