Package twisted :: Package internet :: Module tcp :: Class Port
[show private | hide private]
[frames | no frames]

Type Port

     _SocketCloser --+
                     |
 Ephemeral --+       |
             |       |
    Logger --+       |
             |       |
    object --+       |
             |       |
FileDescriptor --+   |
                 |   |
          BasePort --+
                     |
                    Port

Known Subclasses:
PassableServerPort, Port

I am a TCP server port, listening for connections.

When a connection is accepted, I will call my factory's buildProtocol with the incoming connection as an argument, according to the specification described in twisted.internet.interfaces.IProtocolFactory.

If you wish to change the sort of transport that will be used, my `transport' attribute will be called with the signature expected for Server.__init__, so it can be replaced.
Method Summary
  __init__(self, port, factory, backlog, interface, reactor)
Initialize with a numeric port to listen on.
  __repr__(self)
  connectionLost(self, reason)
Cleans up my socket.
  createInternetSocket(self)
  doRead(self)
Called when my socket is ready for reading.
  getHost(self)
Returns an IPv4Address.
  logPrefix(self)
Returns the name of my class, to prefix log entries with.
  loseConnection(self, connDone)
Stop accepting connections on this port.
  startListening(self)
Create and bind my socket, and begin listening on it.
  stopListening(self, connDone)
Stop accepting connections on this port.
    Inherited from FileDescriptor
  fileno(self)
File Descriptor number for select().
  loseWriteConnection(self)
  pauseProducing(self)
  readConnectionLost(self, reason)
  registerProducer(self, producer, streaming)
Register to receive data from a producer.
  resumeProducing(self)
  startReading(self)
Start waiting for read availability.
  startWriting(self)
Start waiting for write availability.
  stopConsuming(self)
Stop consuming data.
  stopProducing(self)
  stopReading(self)
Stop waiting for read availability.
  stopWriting(self)
Stop waiting for write availability.
  unregisterProducer(self)
Stop consuming data from a producer, without disconnecting.
  write(self, data)
Reliably write some data.
  writeConnectionLost(self, reason)
  writeSequence(self, iovec)
  writeSomeData(self, data)
Write as much as possible of the given data, immediately.
    Inherited from Ephemeral
  __getstate__(self)
  __setstate__(self, state)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
Implements __implemented__ = <implementedBy twisted.internet.tcp.Po...
ClassProvides __provides__ = <zope.interface.declarations.ClassProvide...
int addressFamily = 2                                                                     
int backlog = 50                                                                    
str interface = ''
int sessionno = 0                                                                     
int socketType = 1                                                                     
type transport = twisted.internet.tcp.Server
    Inherited from FileDescriptor
int bufferSize = 65536                                                                 
int connected = 0                                                                     
str dataBuffer = ''
int disconnected = 0                                                                     
int disconnecting = 0                                                                     
int offset = 0                                                                     
NoneType producer = None                                                                  
int producerPaused = 0                                                                     
int SEND_LIMIT = 131072                                                                
int streamingProducer = 0                                                                     
    Inherited from Logger
ClassProvides __providedBy__ = <zope.interface.declarations.ClassProvi...

Method Details

__init__(self, port, factory, backlog=50, interface='', reactor=None)
(Constructor)

Initialize with a numeric port to listen on.
Overrides:
twisted.internet.abstract.FileDescriptor.__init__

connectionLost(self, reason)

Cleans up my socket.
Overrides:
twisted.internet.abstract.FileDescriptor.connectionLost

doRead(self)

Called when my socket is ready for reading.

This accepts a connection and calls self.protocol() to handle the wire-level protocol.
Overrides:
twisted.internet.abstract.FileDescriptor.doRead

getHost(self)

Returns an IPv4Address.

This indicates the server's address.

logPrefix(self)

Returns the name of my class, to prefix log entries with.
Overrides:
twisted.python.log.Logger.logPrefix

loseConnection(self, connDone=<twisted.python.failure.Failure twisted.internet.error.Co...)

Stop accepting connections on this port.

This will shut down my socket and call self.connectionLost(). It returns a deferred which will fire successfully when the port is actually closed.
Overrides:
twisted.internet.abstract.FileDescriptor.loseConnection

startListening(self)

Create and bind my socket, and begin listening on it.

This is called on unserialization, and must be called after creating a server to begin listening on the specified port.

stopListening(self, connDone=<twisted.python.failure.Failure twisted.internet.error.Co...)

Stop accepting connections on this port.

This will shut down my socket and call self.connectionLost(). It returns a deferred which will fire successfully when the port is actually closed.
Overrides:
twisted.internet.abstract.FileDescriptor.loseConnection

Class Variable Details

__implemented__

Type:
Implements
Value:
<implementedBy twisted.internet.tcp.Port>                              

__provides__

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

addressFamily

Type:
int
Value:
2                                                                     

backlog

Type:
int
Value:
50                                                                    

interface

Type:
str
Value:
''                                                                     

sessionno

Type:
int
Value:
0                                                                     

socketType

Type:
int
Value:
1                                                                     

Generated by Epydoc 2.1 on Sat Apr 14 13:20:45 2007 http://epydoc.sf.net