Exemplo n.º 1
0
 def bind(self, sock, ip, port=None):
     # TODO: more realistic implementation
     if port is None:
         port = port_from_user(self.avail_ports[sock.type])
         self.avail_ports[type] += 1
     self.sockets[(sock.type, self.ip, port)] = sock
     return self.ip, port
Exemplo n.º 2
0
 def bind(self, sock, ip, port=None):
     # TODO: more realistic implementation
     if port is None:
         port = port_from_user(self.avail_ports[sock.type])
         self.avail_ports[type] += 1
     self.sockets[(sock.type, self.ip, port)] = sock
     return self.ip, port
Exemplo n.º 3
0
def canonicalized_port(port):
    if isinstance(port, int):
        return port_from_user(port)
    elif isinstance(port, Port):
        return port
    elif port is None:
        return None
    else:
        raise TypeError('unsupported port form')
Exemplo n.º 4
0
def canonicalized_port(port):
    if isinstance(port, int):
        return port_from_user(port)
    elif isinstance(port, Port):
        return port
    elif port is None:
        return None
    else:
        raise TypeError('unsupported port form')