def getservbyname(space, name, proto): """ Get port number associated with an Internet service and protocol""" try: n = rsocket.getservbyname(name, proto) return space.newint(n) except rsocket.RSocketError: return space.w_False
def getservbyname(space, name, w_proto): """getservbyname(servicename[, protocolname]) -> integer Return a port number from a service name 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) try: port = rsocket.getservbyname(name, proto) except SocketError, e: raise converted_error(space, e)