- if verbose: print "Will connect to %s:%s" % (connect_host, connect_port)
-
- listen[1] = 10003
- reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine))
+ if verbose: print("Will connect to %s:%s" % (connect_host, connect_port))
+ if listen[1] is None:
+ listen[1] = 5900
+ ready = False
+ while not ready and listen[1] < 6000:
+ try:
+ reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine), interface=listen[0])
+ ready = True
+ except error.CannotListenError:
+ listen[1] += 1
+ else:
+ reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine))