def getservbyport(space, port, proto): """ Get Internet service which corresponds to port and protocol""" try: n = rsocket.getservbyport(port, proto) return space.newstr(n) except rsocket.RSocketError: return space.w_False
def getprotobynumber(space, pnum): """ Get protocol name associated with protocol number""" try: n = rsocket.getservbyport(pnum) return space.newstr(n) except rsocket.RSocketError: return space.w_False
def getservbyport(space, port, w_proto): """getservbyport(port[, protocolname]) -> string Return the service name from a port number and protocol name. The optional protocol name, if given, should be 'tcp' or 'udp', otherwise any protocol will match. """ if space.is_w(w_proto, space.w_None): proto = None else: proto = space.str_w(w_proto) if port < 0 or port > 0xFFFF: raise OperationError(space.w_ValueError, space.wrap("getservbyport: port must be 0-65535.")) try: service = rsocket.getservbyport(port, proto) except SocketError, e: raise converted_error(space, e)
def getservbyport(space, port, w_proto): """getservbyport(port[, protocolname]) -> string Return the service name from a port number and protocol name. The optional protocol name, if given, should be 'tcp' or 'udp', otherwise any protocol will match. """ if space.is_w(w_proto, space.w_None): proto = None else: proto = space.str_w(w_proto) if port < 0 or port > 0xffff: raise OperationError(space.w_ValueError, space.wrap( "getservbyport: port must be 0-65535.")) try: service = rsocket.getservbyport(port, proto) except SocketError, e: raise converted_error(space, e)