anycall/rpc.py
def create_tcp_rpc_system(hostname=None, port_range=(0,), ping_interval=1, ping_timeout=0.5):
    """
    Creates a TCP based :class:`RPCSystem`.
    
    :param port_range: List of ports to try. If `[0]`, an arbitrary free
        port will be used.
    """
    
    def ownid_factory(listeningport):
        port = listeningport.getHost().port
        return "%s:%s" %(hostname, port)

    def make_client_endpoint(peer):
        host, port = peer.split(":")
        if host == socket.getfqdn():
            host = "localhost"
        return endpoints.TCP4ClientEndpoint(reactor, host, int(port), timeout=5)
    
    if hostname is None:
        hostname = socket.getfqdn()

    server_endpointA = TCP4ServerRangeEndpoint(reactor, port_range)
    pool = connectionpool.ConnectionPool(server_endpointA, make_client_endpoint, ownid_factory)
    return RPCSystem(pool, ping_interval=ping_interval, ping_timeout=ping_timeout)
def create_tcp_rpc_system(hostname=None, port_range=(0,), ping_interval=1, ping_timeout=0.5):
    """
    Creates a TCP based :class:`RPCSystem`.
    
    :param port_range: List of ports to try. If `[0]`, an arbitrary free
        port will be used.
    """
    
    def ownid_factory(listeningport):
        port = listeningport.getHost().port
        return "%s:%s" %(hostname, port)

    def make_client_endpoint(peer):
        host, port = peer.split(":")
        if host == socket.getfqdn():
            host = "localhost"
        return endpoints.TCP4ClientEndpoint(reactor, host, int(port), timeout=5)
    
    if hostname is None:
        hostname = socket.getfqdn()

    server_endpointA = TCP4ServerRangeEndpoint(reactor, port_range)
    pool = connectionpool.ConnectionPool(server_endpointA, make_client_endpoint, ownid_factory)
    return RPCSystem(pool, ping_interval=ping_interval, ping_timeout=ping_timeout)
Creates a TCP based :class:`RPCSystem`.
    
    :param port_range: List of ports to try. If `[0]`, an arbitrary free
        port will be used.