def _setup_connection(self, dstaddr):
    port = randint(10000, 60000)
    (af, socktype, proto, _canonname, _sa) = socket.getaddrinfo(dstaddr, port, socket.AF_INET, socket.SOCK_DGRAM)[0]
    s = socket.socket(af, socktype, proto)
    has_bind = 1
    for _i in range(0, 10):
        try:
            s.bind((INADDR_ANY, randint(10000, 60000)))
            s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
            has_bind = 1
        except socket.error:
            pass
    if (not has_bind):
        raise NetBIOSError('Cannot bind to a good UDP port', ERRCLASS_OS, errno.EAGAIN)
    self.__sock = s
def _setup_connection(self, dstaddr):
    port = randint(10000, 60000)
    (af, socktype, proto, _canonname, _sa) = socket.getaddrinfo(dstaddr, port, socket.AF_INET, socket.SOCK_DGRAM)[0]
    s = socket.socket(af, socktype, proto)
    has_bind = 1
    for _i in range(0, 10):
        try:
            s.bind((INADDR_ANY, randint(10000, 60000)))
            s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
            has_bind = 1
        except socket.error:
            pass
    if (not has_bind):
        raise NetBIOSError('Cannot bind to a good UDP port', ERRCLASS_OS, errno.EAGAIN)
    self.__sock = s