Package twisted :: Package internet :: Module tcp :: Class Port

[show private | hide private]
[frames | no frames]

## Class Port

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

Known Subclasses:
  `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.protocols.protocol.Factory.

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.
| `__getstate__(self)` (inherited from `Ephemeral`)
| `__repr__(self)`
| `__setstate__(self, state)` (inherited from `Ephemeral`)
| ``connectionLost`(self, reason)` Cleans up my socket.
| `createInternetSocket(self)`
| ``doRead`(self)` Called when my socket is ready for reading.
| ``fileno`(self)` File Descriptor number for select(). (inherited from `FileDescriptor`)
| ``getHost`(self)` Returns a tuple of ('INET', hostname, port).
| `log(self, bytes)` (inherited from `Logger`)
| ``logPrefix`(self)` Returns the name of my class, to prefix log entries with.
| ``loseConnection`(self)` Stop accepting connections on this port.
| `pauseProducing(self)` (inherited from `FileDescriptor`)
| ``registerProducer`(self, producer, streaming)` Register to receive data from a producer. (inherited from `FileDescriptor`)
| `resumeProducing(self)` (inherited from `FileDescriptor`)
| ``startListening`(self)` Create and bind my socket, and begin listening on it.
| ``startReading`(self)` Start waiting for read availability. (inherited from `FileDescriptor`)
| ``startWriting`(self)` Start waiting for write availability. (inherited from `FileDescriptor`)
| ``stopConsuming`(self)` Stop consuming data. (inherited from `FileDescriptor`)
| ``stopListening`(self)` Stop accepting connections on this port.
| `stopProducing(self)` (inherited from `FileDescriptor`)
| ``stopReading`(self)` Stop waiting for read availability. (inherited from `FileDescriptor`)
| ``stopWriting`(self)` Stop waiting for write availability. (inherited from `FileDescriptor`)
| ``unregisterProducer`(self)` Stop consuming data from a producer, without disconnecting. (inherited from `FileDescriptor`)
| ``write`(self, data)` Reliably write some data. (inherited from `FileDescriptor`)
| `writeSequence(self, iovec)` (inherited from `FileDescriptor`)
| ``writeSomeData`(self, data)` Write as much as possible of the given data, immediately. (inherited from `FileDescriptor`)

Class Variable Summary
`int` | `addressFamily`
`int` | `backlog`
`string` | `interface`
`class` | `Server`
`int` | `sessionno`
`int` | `socketType`

Method Details

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

Initialize with a numeric port to listen on.

### connectionLost(self, reason)

Cleans up my socket.

### 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.

### loseConnection(self)

Stop accepting connections on this port.

This will shut down my socket and call self.connectionLost().

### 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)

Stop accepting connections on this port.

This will shut down my socket and call self.connectionLost().

Class Variable Details

### addressFamily

  Type:
    `int`
  Value:

        2

### backlog

  Type:
    `int`
  Value:

        5

### interface

  Type:
    `string`
  Value:

        ''

### Server

`Server` = `twisted.internet.tcp.Server`

### sessionno

  Type:
    `int`
  Value:

        0

### socketType

  Type:
    `int`
  Value:

        1

Generated by Epydoc 1.1 on Sat Feb 15 21:17:53 2003 | http://epydoc.sf.net