Part of twisted.internet.endpoints View Source
Construct a stream server endpoint from an endpoint description string.
The format for server endpoint descriptions is a simple string. It is a prefix naming the type of endpoint, then a colon, then the arguments for that endpoint.
For example, you can call it like this to create an endpoint that will listen on TCP port 80:serverFromString(reactor, "tcp:80")Additional arguments may be specified as keywords, separated with colons. For example, you can specify the interface for a TCP server endpoint to bind to like this:
serverFromString(reactor, "tcp:80:interface=127.0.0.1")SSL server endpoints may be specified with the 'ssl' prefix, and the private key and certificate files may be specified by the
privateKey
and certKey
arguments:
serverFromString(reactor, "ssl:443:privateKey=key.pem:certKey=crt.pem")
If a private key file name (privateKey
) isn't provided, a
"server.pem" file is assumed to exist which contains the private
key. If the certificate file name (certKey
) isn't provided,
the private key file is assumed to contain the certificate as well.
serverFromString(reactor, "ssl:443:privateKey=C\:/key.pem:certKey=C\:/cert.pem")finally, the 'unix' prefix may be used to specify a filesystem UNIX socket, optionally with a 'mode' argument to specify the mode of the socket file created by
listen
:
serverFromString(reactor, "unix:/var/run/finger") serverFromString(reactor, "unix:/var/run/finger:mode=660")This function is also extensible; new endpoint types may be registered as
IStreamServerEndpointStringParser
plugins. See that interface for more information.
Parameters | reactor | The server endpoint will be constructed with this reactor. |
description | The strports description to parse. | |
Returns | A new endpoint which can be used to listen with the parameters given by
by description .
(type: IStreamServerEndpoint
) | |
Raises | ValueError | when the 'description' string cannot be parsed. |
Present Since | 10.2 |