Exemplo n.º 1
0
def _getservicename(sin_port, flags):
    if flags & NI_NUMERICSERV:
        sp = lltype.nullptr(_c.cConfig.servent)
    elif flags & NI_DGRAM:
        sp = _c.getservbyport(sin_port, "udp")
    else:
        sp = _c.getservbyport(sin_port, "tcp")

    if sp:
        serv = rffi.charp2str(sp.c_s_name)
    else:
        serv = "%d" % r_uint(_c.ntohs(sin_port))

    return serv
Exemplo n.º 2
0
def _getservicename(sin_port, flags):
    if flags & NI_NUMERICSERV:
        sp = lltype.nullptr(_c.cConfig.servent)
    elif flags & NI_DGRAM:
        sp = _c.getservbyport(sin_port, "udp")
    else:
        sp = _c.getservbyport(sin_port, "tcp")

    if sp:
        serv = rffi.charp2str(sp.c_s_name)
    else:
        serv = "%d" % r_uint(_c.ntohs(sin_port))

    return serv
Exemplo n.º 3
0
def getservbyport(port, proto=None):
    servent = _c.getservbyport(htons(port), proto)
    if not servent:
        raise RSocketError("port/proto not found")
    return rffi.charp2str(servent.c_s_name)
Exemplo n.º 4
0
def getservbyport(port, proto=None):
    servent = _c.getservbyport(htons(port), proto)
    if not servent:
        raise RSocketError("port/proto not found")
    return rffi.charp2str(servent.c_s_name)