t.i.e.serverFromString(reactor, description) : function documentation

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 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=")

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:

       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:


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.

ParametersreactorThe server endpoint will be constructed with this reactor.
descriptionThe strports description to parse. (type: bytes)
ReturnsA new endpoint which can be used to listen with the parameters given by description. (type: IStreamServerEndpoint)
RaisesValueErrorwhen the 'description' string cannot be parsed.
Present Since10.2
API Documentation for Twisted, generated by pydoctor at 2015-01-30 14:14:53.