Package twisted :: Package internet :: Module protocol :: Class BaseProtocol
[show private | hide private]
[frames | no frames]

Class BaseProtocol

Known Subclasses:
ProcessProtocol, 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 Summary
  connectionMade(self)
Called when a connection is made.
  makeConnection(self, transport)
Make a connection to a transport and a server.

Class Variable Summary
Implements __implemented__ = <implementedBy twisted.internet.protoc...
ClassProvides __providedBy__ = <zope.interface.declarations.ClassProvi...
ClassProvides __provides__ = <zope.interface.declarations.ClassProvide...
int connected = 0                                                                     
NoneType transport = None                                                                  

Method Details

connectionMade(self)

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.

makeConnection(self, transport)

Make a connection to a transport and a server.

This sets the 'transport' attribute of this Protocol, and calls the connectionMade() callback.

Class Variable Details

__implemented__

Type:
Implements
Value:
<implementedBy twisted.internet.protocol.BaseProtocol>                 

__providedBy__

Type:
ClassProvides
Value:
<zope.interface.declarations.ClassProvides object at 0x35553f0>        

__provides__

Type:
ClassProvides
Value:
<zope.interface.declarations.ClassProvides object at 0x35553f0>        

connected

Type:
int
Value:
0                                                                     

transport

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.1 on Thu Aug 16 09:55:13 2007 http://epydoc.sf.net