Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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)
Example #6
0
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)