I am a beginner for Twisted. Recently, I am reading the book “Twisted Network Programming Essentials”.The Example 2-3 In this book as below:
class QuickDisconnectProtocol(protocol.Protocol):
def connectionMade(self):
print "Connected to %s." % self.transport.getPeer( ).host
self.transport.loseConnection( )
==================================
self.transport.loseConnection( )
where is the member “transport”?
I couldn’t find that one in Protocol.
Same question when it comes to Ex2-4…
Does anyone have a clue on how to read Twisted Documents? Thanks!
The transport is the connection to the whatever you’re using, like telnet, SSH, a file, etc. Search the online API docs for
transportand see i.e.http://twistedmatrix.com/documents/8.2.0/api/twisted.conch.ssh.transport.SSHTransportBase.html
Here are some if the transports that exist, from
http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.interfaces.ITransport.html
Depending on where you want to connect to, you use one of them when you call
makeConnection(transport), and when you do that, it becomes an attribute of the protocol.