def connect(self, target, acceptor, wrapper=None):
        """
        Initiate a connection from the tendril manager's endpoint.
        Once the connection is completed, a TCPTendril object will be
        created and passed to the given acceptor.

        :param target: The target of the connection attempt.
        :param acceptor: A callable which will initialize the state of
                         the new TCPTendril object.
        :param wrapper: A callable taking, as its first argument, a
                        socket.socket object.  The callable must
                        return a valid proxy for the socket.socket
                        object, which will subsequently be used to
                        communicate on the connection.

        For passing extra arguments to the acceptor or the wrapper,
        see the ``TendrilPartial`` class; for chaining together
        multiple wrappers, see the ``WrapperChain`` class.
        """

        # Call some common sanity-checks
        super(TCPTendrilManager, self).connect(target, acceptor, wrapper)

        # Set up the socket
        sock = socket.socket(self.addr_family, socket.SOCK_STREAM)

        with utils.SocketCloser(sock, ignore=[application.RejectConnection]):
            # Bind to our endpoint
            sock.bind(self.endpoint)

            # Connect to our target
            sock.connect(target)

            # Call any wrappers
            if wrapper:
                sock = wrapper(sock)

            # Now, construct a Tendril
            tend = TCPTendril(self, sock)

            # Finally, set up the application
            tend.application = acceptor(tend)

            # OK, let's track the tendril
            self._track_tendril(tend)

            # Start the tendril
            tend._start()

            # Might as well return the tendril, too
            return tend

        # The acceptor raised a RejectConnection exception, apparently
        sock.close()
        return None
def connect ( self , target , acceptor , wrapper = None ) : super ( TCPTendrilManager , self ) . connect ( target , acceptor , wrapper ) sock = socket . socket ( self . addr_family , socket . SOCK_STREAM ) with utils . SocketCloser ( sock , ignore = [ application . RejectConnection ] ) : sock . bind ( self . endpoint ) sock . connect ( target ) if wrapper : sock = wrapper ( sock ) tend = TCPTendril ( self , sock ) tend . application = acceptor ( tend ) self . _track_tendril ( tend ) tend . _start ( ) return tend sock . close ( ) return None
Initiate a connection from the tendril manager's endpoint.
        Once the connection is completed, a TCPTendril object will be
        created and passed to the given acceptor.

        :param target: The target of the connection attempt.
        :param acceptor: A callable which will initialize the state of
                         the new TCPTendril object.
        :param wrapper: A callable taking, as its first argument, a
                        socket.socket object.  The callable must
                        return a valid proxy for the socket.socket
                        object, which will subsequently be used to
                        communicate on the connection.

        For passing extra arguments to the acceptor or the wrapper,
        see the ``TendrilPartial`` class; for chaining together
        multiple wrappers, see the ``WrapperChain`` class.