I'm creating TCP client socket with Twisted. I need to check connection status in a loop interval in connectionMade method.
from twisted.internet import reactor, protocol
class ClientProtocol(protocol.Protocol):
def connectionMade(self):
while not thread_obj.stopped.wait(10):
print ('ping')
self.transport.write(b'test') # Byte value
For check connection losing, i manually disconnect my network And I checked some variables after that as bellow:
print (self.connected)
print (self.transport.connector.state)
print (self.transport.connected)
print (self.transport.reactor.running)
print (self.transport.socket._closed)
print (self.factory.protocol.connected)
print (self._writeDissconnected)
But any variables value didn't change after disconnecting my network :(
My question is: which variables will be set when the connection lost? I mean how can i check the connection status and if it's disconnect, how can i reconnect that?