Go to the latest version of this document.

# ``twisted`.`application`.`internet``

module documentation
(source)

Reactor-based Services

Here are services to run clients, servers and periodic services using the reactor.

If you want to run a server service, `StreamServerEndpointService` defines a service that can wrap an arbitrary `IStreamServerEndpoint` as an `IService`. See also `twisted.application.strports.service` for constructing one of these directly from a descriptive string.

Additionally, this module (dynamically) defines various Service subclasses that let you represent clients and servers in a Service hierarchy. Endpoints APIs should be preferred for stream server services, but since those APIs do not yet exist for clients or datagram services, many of these are still useful.

They are as follows:

      TCPServer, TCPClient,
      UNIXServer, UNIXClient,
      SSLServer, SSLClient,
      UDPServer,
      UNIXDatagramServer, UNIXDatagramClient,
      MulticastServer

These classes take arbitrary arguments in their constructors and pass them straight on to their respective reactor.listenXXX or reactor.connectXXX calls.

For example, the following service starts a web server on port 8080: `TCPServer(8080, server.Site(r))`. See the documentation for the reactor.listen/connect* methods for more information.

Class | `ClientService` | A `ClientService` maintains a single outgoing connection to a client endpoint, reconnecting after a configurable timeout when a connection fails, either before or after connecting.
Class | `CooperatorService` | Simple `service.IService` which starts and stops a `twisted.internet.task.Cooperator`.
Class | `MulticastServer` | Undocumented
Class | `SSLClient` | Undocumented
Class | `SSLServer` | Undocumented
Class | `StreamServerEndpointService` | A `StreamServerEndpointService` is an `IService` which runs a server on a listening port described by an `IStreamServerEndpoint`.
Class | `TCPClient` | Undocumented
Class | `TCPServer` | Undocumented
Class | `TimerService` | Service to periodically call a function
Class | `UDPServer` | Undocumented
Class | `UNIXClient` | Undocumented
Class | `UNIXDatagramClient` | Undocumented
Class | `UNIXDatagramServer` | Undocumented
Class | `UNIXServer` | Undocumented
Function | `backoffPolicy` | A timeout policy for `ClientService` which computes an exponential backoff interval with configurable parameters.
Class | `_AbstractClient` | No summary
Class | `_AbstractServer` | No summary
Class | `_VolatileDataService` | Undocumented
Variable | `_clientDoc` | Undocumented
Variable | `_serverDoc` | Undocumented

def backoffPolicy(initialDelay: `float` = 1.0, maxDelay: `float` = 60.0, factor: `float` = 1.5, jitter: `Callable[[], float]` = _goodEnoughRandom) -> `Callable[[int], float]`: (source)

A timeout policy for `ClientService` which computes an exponential backoff interval with configurable parameters.

Parameters
initialDelay:`float` | Delay for the first reconnection attempt (default 1.0s).
maxDelay:`float` | Maximum number of seconds between connection attempts (default 60 seconds, or one minute). Note that this value is before jitter is applied, so the actual maximum possible delay is this value plus the maximum possible result of `jitter()`.
factor:`float` | A multiplicative factor by which the delay grows on each failed reattempt. Default: 1.5.
jitter:0-argument callable returning `float` | A 0-argument callable that introduces noise into the delay. By default, `random.random`, i.e. a pseudorandom floating-point value between zero and one.

Returns
see `ClientService.__init__`'s `retryPolicy` argument. | a 1-argument callable that, given an attempt count, returns a floating point number; the number of seconds to delay.

Present Since
16.1.0

_clientDoc: `str` = (source)

Undocumented

_serverDoc: `str` = (source)

Undocumented