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

## Class Port

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

Known Subclasses:
  `Port`, `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)`
| `_preMakeConnection(self, transport)`
| ``connectionLost`(self, reason)` Cleans up my socket.
| `createInternetSocket(self)`
| ``doRead`(self)` Called when my socket is ready for reading.
| ``getHost`(self)` Returns a tuple of ('INET', hostname, port).
| ``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 BasePort
| ``doWrite`(self)` Raises a RuntimeError
Inherited from FileDescriptor
| ``_postLoseConnection`(self)` Called after a loseConnection(), when all data has been written.
| ``fileno`(self)` File Descriptor number for select().
| ``pauseProducing`(self)`
| ``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.
| ``writeSequence`(self, iovec)`
| ``writeSomeData`(self, data)` Write as much as possible of the given data, immediately.
Inherited from Ephemeral
| ``__getstate__`(self)`
| ``__setstate__`(self, state)`

Class Variable Summary
`int` | `addressFamily` = 2
`int` | `backlog` = 5
`str` | `interface` = `''`
`int` | `sessionno` = 0
`int` | `socketType` = 1
`class` | `transport` = `twisted.internet.tcp.Server`
Inherited from FileDescriptor
`tuple` | `__implements__` = `(<class twisted.internet.interfaces.IPr...`
`int` | `bufferSize` = 65536
`int` | `connected` = 0
`str` | `dataBuffer` = `''`
`int` | `disconnected` = 0
`int` | `disconnecting` = 0
`int` | `offset` = 0
`NoneType` | `producer` = None
`int` | `producerPaused` = 0
`int` | `streamingProducer` = 0

Method Details

### __init__(self, port, factory, backlog=5, 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.

### getHost(self) Returns a tuple of ('INET', hostname, port). 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(). 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(). Overrides: `twisted.internet.abstract.FileDescriptor.loseConnection`

Class Variable Details

    ### addressFamily Type: `int` Value:
        2

    ### backlog Type: `int` Value:
        5

    ### interface Type: `str` Value:
        ''

    ### sessionno Type: `int` Value:
        0

    ### socketType Type: `int` Value:
        1

Generated by Epydoc 2.0 on Sat Oct 25 00:55:13 2003 | http://epydoc.sf.net