Exemplo n.º 1
0
 def connect(self, address):
     self.connected = False
     err = self.socket.connect_ex(address)
     if err in (EINPROGRESS, EALREADY, EWOULDBLOCK) \
     or err == EINVAL and os.name in ('nt', 'ce'):
         return
     if err in (0, EISCONN):
         self.addr = address
         self.handle_connect_event()
     else:
         raise socket.error(err, errorcode[err])
Exemplo n.º 2
0
    def handle_write_event(self):
        if self.accepting:
            # Accepting sockets shouldn't get a write event.
            # We will pretend it didn't happen.
            return

        if not self.connected:
            #check for errors
            err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
            if err != 0:
                raise socket.error(err, _strerror(err))

            self.handle_connect_event()
        self.handle_write()
Exemplo n.º 3
0
 def handle_connect_event(self):
     err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
     if err != 0:
         raise socket.error(err, _strerror(err))
     self.handle_connect()
     self.connected = True