tping server every 5 minutes to make sure the link is not down - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f389cd6ad5f7a9233544aba76355db52fd40a80d DIR parent 524d913bbaea10dc731b468a4570025be592b940 HTML Author: thomasv <thomasv@gitorious> Date: Wed, 2 May 2012 16:04:00 +0200 ping server every 5 minutes to make sure the link is not down Diffstat: M interface.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- DIR diff --git a/interface.py b/interface.py t@@ -212,7 +212,7 @@ class TcpStratumInterface(Interface): def __init__(self, host, port): Interface.__init__(self, host, port) self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - self.s.settimeout(5) + self.s.settimeout(5*60) self.s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) try: self.s.connect(( self.host, self.port)) t@@ -227,7 +227,9 @@ class TcpStratumInterface(Interface): out = '' while self.is_connected: try: msg = self.s.recv(1024) - except socket.timeout: + except socket.timeout: + # ping the server with server.version, as a real ping does not exist yet + self.send([('server.version', [ELECTRUM_VERSION])]) continue out += msg if msg == '':