Im new to Twisted. Suppose im writing a client which connects over TCP to a server.I would like to know what the difference is between connectionLost defined in Protocol versus clientConnectionLost defined in Factory. For example consider the following echo client which connects to an echo server:
from twisted.internet import reactor, protocol
class EchoClient(protocol.Protocol):
def connectionMade(self):
self.transport.write("Hello, World!")
def connectionLost(self,reason):
print "connectionLost called "
def dataReceived(self,data):
print "Server said: ", data
class EchoFactory(protocol.ClientFactory):
def buildProtocol(self, addr):
return EchoClient()
def clientConnectionFailed(self, connector, reason):
print "Connection failed"
reactor.stop()
def clientConnectionLost(self, connector, reason):
print "clientConnectionLost called"
reactor.stop()
reactor.connectTCP("localhost",8000,EchoFactory())
reactor.run()
When i terminate the echo server program, both "connectionLost called" and "clientConnectionLost called" gets printed. So what is the difference between the two ?
Thanks