Package twisted :: Package application :: Module strports

[frames | no frames]

## Module twisted.application.strports

Port description language

This module implements a description mini-language for ports, and provides functions to parse it and to use it to directly construct appropriate network server services or to directly listen on them.

Here are some examples:

    >>> s=service("80", server.Site())
    >>> s=service("tcp:80", server.Site())
    >>> s=service("tcp:80:interface=127.0.0.1", server.Site())
    >>> s=service("ssl:443", server.Site())
    >>> s=service("ssl:443:privateKey=mykey.pem", server.Site())
    >>> s=service("ssl:443:privateKey=mykey.pem:certKey=cert.pem", server.Site())
    >>> s=service("unix:/var/run/finger", FingerFactory())
    >>> s=service("unix:/var/run/finger:mode=660", FingerFactory())
    >>> p=listen("80", server.Site())
    >>> p=listen("tcp:80", server.Site())
    >>> p=listen("tcp:80:interface=127.0.0.1", server.Site())
    >>> p=listen("ssl:443", server.Site())
    >>> p=listen("ssl:443:privateKey=mykey.pem", server.Site())
    >>> p=listen("ssl:443:privateKey=mykey.pem:certKey=cert.pem", server.Site())
    >>> p=listen("unix:/var/run/finger", FingerFactory())
    >>> p=listen("unix:/var/run/finger:mode=660", FingerFactory())

See specific function documentation for more information.

API Stability: unstable

Maintainer: Moshe Zadka

Function Summary
| `_parse(description)`
| `_parseSSL(factory, port, privateKey, certKey, sslmethod, interface, backlog)`
| `_parseTCP(factory, port, interface, backlog)`
| `_parseUNIX(factory, address, mode, backlog)`
| `_tokenize(description)`
`twisted.internet.interfaces.IListeningPort` | ``listen`(description, factory, default)` Listen on a port corresponding to a description
`tuple` | ``parse`(description, factory, default)` Parse a description of a reliable virtual circuit server
`twisted.application.service.IService` | ``service`(description, factory, default)` Return the service corresponding to a description

Variable Summary
`dict` | `_funcs` = `{'ssl': <function _parseSSL at 0x871edc4>, 'uni...`
`int` | `_OP` = 0
`int` | `_STRING` = 1

Function Details

### listen(description, factory, default=None)

Listen on a port corresponding to a description

  Parameters:
    `description`
    (type=`str`)
    `factory`
    (type=

    `twisted.internet.interfaces.IProtocolFactory`)

    `default`
    (type=`str` or `None`)
  Returns:

    the port corresponding to a description of a reliable virtual circuit server.

    See the documentation of the `parse` function for description of the semantics of the arguments.
    (type=`twisted.internet.interfaces.IListeningPort`)

### parse(description, factory, default=None)

Parse a description of a reliable virtual circuit server

  Parameters:
    `description`
    (type=`str`)
    `factory`
    (type=

    `twisted.internet.interfaces.IProtocolFactory`)

    `default`
    (type=`str` or `None`)
  Returns:
    a tuple of string, tuple and dictionary. The string is the name of the method (sans `'listen'`) to call, and the tuple and dictionary are the arguments and keyword arguments to the method.
    (type=`tuple`)

### service(description, factory, default=None)

Return the service corresponding to a description

  Parameters:
    `description`
    (type=`str`)
    `factory`
    (type=

    `twisted.internet.interfaces.IProtocolFactory`)

    `default`
    (type=`str` or `None`)
  Returns:

    the service corresponding to a description of a reliable virtual circuit server.

    See the documentation of the `parse` function for description of the semantics of the arguments.
    (type=`twisted.application.service.IService`)

Variable Details

### _funcs

  Type:
    `dict`
  Value:

        {'ssl': <function _parseSSL at 0x871edc4>,
         'tcp': <function _parseTCP at 0x853ad64>,
         'unix': <function _parseUNIX at 0x86a89e4>}

### _OP

  Type:
    `int`
  Value:

        0

### _STRING

  Type:
    `int`
  Value:

        1

Generated by Epydoc 2.0 on Sat May 15 20:08:44 2004 | http://epydoc.sf.net