Part of twisted.internet.endpoints View Source
The format for server endpoint descriptions is a simple byte 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, b"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, b"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, b"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.
You may escape colons in arguments with a backslash, which you will need to use if you want to specify a full pathname argument on Windows:
serverFromString(reactor, b"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, b"unix:/var/run/finger") serverFromString(reactor, b"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. (type: bytes ) | |
Returns | A new endpoint which can be used to listen with the parameters given by
description . (type: IStreamServerEndpoint ) | |
Raises | ValueError | when the 'description' string cannot be parsed. |
Present Since | 10.2 |