From: Claudio-Daniel Freire Date: Thu, 25 Aug 2011 15:40:22 +0000 (+0200) Subject: Implement UDP handshake in tunchannel, so that other testbeds can use it X-Git-Tag: nepi-3.0.0~268 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cb062c1422d542d95ba479733533fd852f3032b1;p=nepi.git Implement UDP handshake in tunchannel, so that other testbeds can use it --- diff --git a/src/nepi/testbeds/planetlab/scripts/tun_connect.py b/src/nepi/testbeds/planetlab/scripts/tun_connect.py index ae7a0cc4..92f7fedd 100644 --- a/src/nepi/testbeds/planetlab/scripts/tun_connect.py +++ b/src/nepi/testbeds/planetlab/scripts/tun_connect.py @@ -775,34 +775,7 @@ try: raise AssertionError, "Error: need a remote endpoint in UDP mode" # Wait for other peer - endme = False - def keepalive(): - while not endme and not TERMINATE: - try: - rsock.send('') - except: - pass - time.sleep(1) - try: - rsock.send('') - except: - pass - keepalive_thread = threading.Thread(target=keepalive) - keepalive_thread.start() - retrydelay = 1.0 - for i in xrange(30): - if TERMINATE: - raise OSError, "Killed" - try: - heartbeat = rsock.recv(10) - break - except: - time.sleep(min(30.0,retrydelay)) - retrydelay *= 1.1 - else: - heartbeat = rsock.recv(10) - endme = True - keepalive_thread.join() + tunchannel.udp_handshake(TERMINATE, rsock) remote = os.fdopen(rsock.fileno(), 'r+b', 0) else: diff --git a/src/nepi/util/tunchannel_impl.py b/src/nepi/util/tunchannel_impl.py index cecd7297..611e7ac6 100644 --- a/src/nepi/util/tunchannel_impl.py +++ b/src/nepi/util/tunchannel_impl.py @@ -215,6 +215,7 @@ class TunChannel(object): else: rsock.bind((local_addr,local_port)) rsock.connect((peer_addr,peer_port)) + tunchannel.udp_handshake(TERMINATE, rsock) remote = os.fdopen(rsock.fileno(), 'r+b', 0) elif listen: # accept tcp connections