t.i.p.BaseProtocol : class documentation

Part of twisted.internet.protocol View Source View In Hierarchy

Known subclasses: twisted.internet.protocol.ProcessProtocol, twisted.internet.protocol.Protocol

This is the abstract superclass of all protocols.

If you are going to write a new protocol for Twisted, start here. The docstrings of this class explain how you can get started. Any protocol implementation, either client or server, should be a subclass of me.

My API is quite simple. Implement dataReceived(data) to handle both event-based and synchronous input; output can be sent through the 'transport' attribute, which is to be an instance that implements twisted.internet.interfaces.ITransport.

Some subclasses exist already to help you write common types of protocols: see the twisted.protocols.basic module for a few of them.
Method makeConnection Make a connection to a transport and a server.
Method connectionMade Called when a connection is made.
def makeConnection(self, transport): (source)

Make a connection to a transport and a server.

This sets the 'transport' attribute of this Protocol, and calls the connectionMade() callback.
def connectionMade(self): (source)
overridden in twisted.conch.insults.helper.TerminalBuffer, twisted.conch.insults.insults.ClientProtocol, twisted.conch.insults.insults.ServerProtocol, twisted.conch.scripts.cftp.StdioClient, twisted.conch.ssh.filetransfer.FileTransferClient, twisted.conch.ssh.session._ProtocolWrapper, twisted.conch.ssh.session.SSHSessionProcessProtocol, twisted.conch.ssh.transport.SSHTransportBase, twisted.conch.stdio.TerminalProcessProtocol, twisted.conch.telnet.AuthenticatingTelnetProtocol, twisted.conch.telnet.AuthenticatingTelnetProtocol, twisted.conch.telnet.TelnetBootstrapProtocol, twisted.conch.telnet.TelnetTransport, twisted.mail.imap4.IMAP4Client, twisted.mail.imap4.IMAP4Server, twisted.mail.pop3.POP3, twisted.mail.pop3client.POP3Client, twisted.mail.smtp.SMTP, twisted.mail.smtp.SMTPClient, twisted.names.dns.DNSProtocol, twisted.news.nntp.NNTPServer, twisted.news.nntp.UsenetClientProtocol, twisted.protocols.dict.DictClient, twisted.protocols.ftp.DTP, twisted.protocols.ftp.FTP, twisted.protocols.ftp.FTPOverflowProtocol, twisted.protocols.policies.ProtocolWrapper, twisted.protocols.portforward.ProxyClient, twisted.protocols.portforward.ProxyServer, twisted.protocols.postfix.PostfixTCPMapServer, twisted.protocols.socks.SOCKSv4, twisted.protocols.socks.SOCKSv4Outgoing, twisted.protocols.telnet.Telnet, twisted.protocols.wire.Chargen, twisted.protocols.wire.Daytime, twisted.protocols.wire.QOTD, twisted.protocols.wire.Time, twisted.protocols.wire.Who, twisted.runner.inetd.InetdProtocol, twisted.runner.procmon.LoggingProtocol, twisted.spread.banana.Banana, twisted.web.http.HTTPChannel, twisted.web.http.HTTPClient, twisted.web.sux.XMLParser, twisted.web.twcgi.CGIProcessProtocol, twisted.web.woven.flashconduit.FlashConduit, twisted.web2.channel.cgi.CGIChannelRequest, twisted.web2.channel.http.HTTPChannel, twisted.web2.channel.http.OverloadedServerProtocol, twisted.web2.stream._ProcessStreamerProtocol, twisted.web2.twcgi.CGIProcessProtocol, twisted.web2.twscgi.SCGIClientProtocol, twisted.words.protocols.irc.DccFileReceive, twisted.words.protocols.irc.DccSendProtocol, twisted.words.protocols.irc.IRC, twisted.words.protocols.irc.IRCClient, twisted.words.protocols.msn.FileReceive, twisted.words.protocols.msn.FileSend, twisted.words.protocols.msn.MSNEventBase, twisted.words.protocols.oscar.OscarConnection, twisted.words.protocols.toc.GetFileTransfer, twisted.words.protocols.toc.TOC, twisted.words.protocols.toc.TOCClient, twisted.words.xish.xmlstream.XmlStream

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.