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
def ntohs(x): return rffi.cast(lltype.Signed, _c.ntohs(x))