Permalink
Browse files

set keep alive only for TCP sockets

  • Loading branch information...
1 parent 305d78b commit fa165ee5fc3da832cafff294ae1ae437441f7cf3 @m0mchil committed Nov 16, 2012
Showing with 6 additions and 4 deletions.
  1. +1 −1 StratumSource.py
  2. +5 −3 poclbm.py
View
@@ -90,7 +90,7 @@ def loop(self):
if not self.options.proxy:
- self.socket = socket.nodelay_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((address, int(port)))
else:
proxy_proto, user, pwd, proxy_host = self.options.proxy[:4]
View
@@ -13,11 +13,13 @@
realsocket = socket.socket
def socketwrap(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
sockobj = realsocket(family, type, proto)
- sockobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
- sockobj.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
+ if type == socket.SOCK_STREAM:
+ sockobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
+ sockobj.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
sockobj.settimeout(5)
return sockobj
-socket.nodelay_socket = socketwrap
+socket.socket = socketwrap
+
usage = "usage: %prog [OPTION]... SERVER[#tag]...\nSERVER is one or more [http[s]|stratum://]user:pass@host:port (required)\n[#tag] is a per SERVER user friendly name displayed in stats (optional)"
parser = OptionParser(version=VERSION, usage=usage)

0 comments on commit fa165ee

Please sign in to comment.