关于扭曲的文档

2024-05-19 00:00:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Twisted的初学者。最近,我在读《Twisted Network Programming Essentials》一书,本书中的示例2-3如下:

class QuickDisconnectProtocol(protocol.Protocol): 

def connectionMade(self): 

    print "Connected to %s." % self.transport.getPeer( ).host 

    self.transport.loseConnection( ) 

================================

self.transport.loseConnection( )

会员“交通”在哪里? 我在协议里找不到那个。在

同样的问题,当谈到Ex2-4。。。在

有人知道如何阅读扭曲的文档吗?谢谢!在


Tags: self示例deftwistednetworkprotocolclassprogramming
1条回答
网友
1楼 · 发布于 2024-05-19 00:00:25
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 a connection to a transport and a server.
    This sets the 'transport' attribute of this Protocol, and calls the connectionMade() 
    callback.
    """

传输是到您正在使用的任何东西(如telnet、SSH、文件等)的连接

http://twistedmatrix.com/documents/8.2.0/api/twisted.conch.ssh.transport.SSHTransportBase.html

如果有运输工具 http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.interfaces.ITransport.html

^{pr2}$

根据您想连接到的位置,您可以在调用makeConnection(transport)时使用其中一个,当您这样做时,将成为协议的一个属性。在

相关问题 更多 >

    热门问题