qmsk/net/transport/client.py
author Tero Marttila <terom@fixme.fi>
Mon, 31 Aug 2009 22:19:16 +0300
branchconnect-async
changeset 45 bb49bf8222ed
parent 28 020c89baaa33
permissions -rw-r--r--
initial async connect attempt
"""
    Abstract Client interface
"""

class Client (object) :
    """
        A Client establishes a connection to some remote Service.
        
        This is an abstract base class that is further impemented by e.g. TCP or SSL.

        Note that a Client behaves more like a factory, such that the Client itself is not a Transport, one must instead
        call .connect(), rather like one must call Service.accept().
    """

    def __init__ (self, endpoint) :
        """
            Connect to the given remote endpoint.

                endpoint        - the remote Endpoint to connect to
        """

        raise NotImplementedError()

    def connect (self, cls=None) :
        """
            Perform the connect operation, returning a new Transport.
                
                cls         - optional transport-specific type to use for the new connection.
        """

        raise NotImplementedError()

    def connect_async (self, cls=None, reactor=None) :
        raise NotImplementedError()