python - About Twisted Documents -
i beginner twisted. recently, reading book "twisted network programming essentials".the example 2-3 in book below:
class quickdisconnectprotocol(protocol.protocol): def connectionmade(self): print "connected %s." % self.transport.getpeer( ).host self.transport.loseconnection( )
==================================
self.transport.loseconnection( )
where member "transport"? couldn't find 1 in protocol.
same question when comes ex2-4...
does have clue on how read twisted documents? thanks!
def makeconnection(self, transport): ([source][1]) """ overridden in twisted.protocols.amp.binaryboxprotocol, twisted.protocols.ftp.protocolwrapper, twisted.protocols.ftp.senderprotocol, twisted.protocols.policies.protocolwrapper, twisted.protocols.stateful.statefulprotocol` make connection transport , server. sets 'transport' attribute of protocol, , calls connectionmade() callback. """
the transport connection whatever you're using, telnet, ssh, file, etc. search online api docs transport
, see i.e.
http://twistedmatrix.com/documents/8.2.0/api/twisted.conch.ssh.transport.sshtransportbase.html
here if transports exist, http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.interfaces.itransport.html
known subclasses: twisted.conch.insults.insults.iterminaltransport, twisted.conch.telnet.itelnettransport, twisted.internet.interfaces.iprocesstransport, twisted.internet.interfaces.itcptransport known implementations: twisted.conch.ssh.channel.sshchannel, twisted.internet._posixstdio.standardio, twisted.internet._win32stdio.standardio, twisted.internet.abstract.filedescriptor, twisted.internet.iocpreactor.abstract.filehandle, twisted.internet.protocol.filewrapper, twisted.protocols.loopback._loopbacktransport, twisted.protocols.loopback.loopbackrelay
depending on want connect to, use 1 of them when call makeconnection(transport)
, , when that, becomes attribute of protocol.
Comments
Post a Comment