示例#1
0
def get_addr(hostname, socktype, protocol, port, address_to_fill):
    hostent = _c.gethostbyname(hostname)

    if not hostent:
        raise GAIError(EAI_FAIL)

    hname, aliases, address_list = gethost_common("", hostent)

    result = []

    for address in address_list:
        if address.family == _c.AF_INET:
            a = address.lock(_c.sockaddr_in)
            rffi.setintfield(a, 'c_sin_port', port & 0xffff)
            address.unlock()
        a = address.lock()
        addr = make_address(a, address.addrlen, address_to_fill)
        address.unlock()
        result.append((
            address.family,
            socktype,
            protocol,
            "",  # XXX canonname?
            addr))

    return result
示例#2
0
def get_addr(hostname, socktype, protocol, port, address_to_fill):
    hostent = _c.gethostbyname(hostname)

    if not hostent:
        raise GAIError(EAI_FAIL)

    hname, aliases, address_list = gethost_common("", hostent)
        
    result = []

    for address in address_list:
        if address.family == _c.AF_INET:
            a = address.lock(_c.sockaddr_in)
            rffi.setintfield(a, 'c_sin_port', r_uint(port) & 0xffff)
            address.unlock()
        a = address.lock()
        addr = make_address(a, address.addrlen, address_to_fill)
        address.unlock()
        result.append((address.family,
                       socktype,
                       protocol,
                       "", # XXX canonname?
                       addr))

    return result
示例#3
0
文件: rsocket.py 项目: alkorzt/pypy
def gethostbyname_ex(name):
    # XXX use gethostbyname_r() if available, and/or use locks if not
    addr = gethostbyname(name)
    hostent = _c.gethostbyname(name)
    return gethost_common(name, hostent, addr)
示例#4
0
def gethostbyname_ex(name):
    # XXX use gethostbyname_r() if available, and/or use locks if not
    addr = gethostbyname(name)
    hostent = _c.gethostbyname(name)
    return gethost_common(name, hostent, addr)