[Twisted-Python] best way to turn on SO_KEEPALIVE option on all sockets
Hello, I was wondering what is the best way to turn on KEEPALIVE option on all sockets opened by my twisted server. I have inserted s.setsockopt(socket.SOL_SOCKET,socket.SO_KEEPALIVE,1) line into twisted/internet/base.py class BasePort(abstract.FileDescriptor): """Basic implementation of a ListeningPort.""" addressFamily = None socketType = None def createInternetSocket(self): s = socket.socket(self.addressFamily, self.socketType) s.setblocking(0) ++ s.setsockopt(socket.SOL_SOCKET,socket.SO_KEEPALIVE,1) but I am wondering if there is a better way of doing this, without actually modyfying twsited code... Thanks Alec Matusis.
On Thu, 2005-02-10 at 18:22 -0800, Alec Matusis wrote:
I was wondering what is the best way to turn on KEEPALIVE option on all sockets opened by my twisted server.
In your Protocol's connectionMade do self.transport.setTCPKeepAlive(True) http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.I... is the documentation for the TCP transport's interface.
participants (2)
-
Alec Matusis
-
Itamar Shtull-Trauring