예제 #1
0
def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = MP.address_type(address)
    s = socket.socket(getattr(socket, family))
    defTimeOut = socket.getdefaulttimeout()
    s.settimeout(30)
    t = MP._init_timeout()

    while 1:
        try:
            s.connect(address)
        except socket.error as e:
            if e.args[0] != errno.ECONNREFUSED or MP._check_timeout(t):
                MP.debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
    else:
        raise
    s.settimeout(defTimeOut)

    fd = MP.duplicate(s.fileno())
    conn = MP._multiprocessing.Connection(fd)
    s.close()
    return conn
예제 #2
0
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = MP.address_type(address)
    s = socket.socket(getattr(socket, family))
    defTimeOut = socket.getdefaulttimeout()
    s.settimeout(30)
    t = MP._init_timeout()

    while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED or MP._check_timeout(t):
                MP.debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
    else:
        raise
    s.settimeout(defTimeOut)

    fd = MP.duplicate(s.fileno())
    conn = MP._multiprocessing.Connection(fd)
    s.close()
    return conn


#MP.SocketClient = SocketClient
예제 #3
0
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = MP.address_type(address)
    s = socket.socket( getattr(socket, family) )
    defTimeOut = socket.getdefaulttimeout()
    s.settimeout(30)
    t = MP._init_timeout()

    while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED or MP._check_timeout(t):
                MP.debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
    else:
        raise
    s.settimeout(defTimeOut)

    fd = MP.duplicate(s.fileno())
    conn = MP._multiprocessing.Connection(fd)
    s.close()
    return conn


#MP.SocketClient = SocketClient
예제 #4
0
        t = _init_timeout()

        while 1:
            try:
                s.connect(address)
            except socket.error, e:
                if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
                    debug('failed to connect to address %s', address)
                    raise
                time.sleep(0.01)
            else:
                break
        else:
            raise

        fd = duplicate(s.fileno())
        conn = _multiprocessing.Connection(fd)
        s.close()
        ## authenticate
        answer_challenge(conn, authkey)
        deliver_challenge(conn, authkey)
        return conn
    ## end of copy

    def connectClientIPv6(address, authkey):
        try:
            client = SocketClientv6(address, authkey)
        except socket.error:
            return None
        return SocketConnection(client)