def _server_connect_bridge_fn(self):
        """Bridge callback function for non-blocking socket connects

        This should be set as the server_bridge_fn before calling socket.connect
        on a non-blocking server_socket."""
        error = self.server_socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
        if error:
            self.logger.info("Failed to connect to endpoint %s:%s errno %s",
                    self.server_addr, self.server_port, error)
            return False

        self._on_server_connected()
        return True
Bridge callback function for non-blocking socket connects

        This should be set as the server_bridge_fn before calling socket.connect
        on a non-blocking server_socket.
nogotofail/mitm/connection/connection.py