Some individuals have been asking about how to setup the “secure_stream” connection type. Some speculated that you should somehow plug it into “reliable_stream”.
That is not accurate.
The truth is, “secure_stream”, from the perspective of Playground, is an independent connection type. The stacking is done in the factories. For example, suppose you’ve created a new SecureStreamServer and SecureStreamClient classes in module a.b (both are StackingFactory instances that produce SecureStreamProtocol instances). You would create your plugin factory functions something like this:
def secureStreamServerStack(topFactory): return PtclServer(SecureStreamServer(topFactory)) def secureStreamClientStack(topFactory): return PtclClient(SecureStreamClient(topFactory))
And your playground.conf file would look something like this:
=====connection_types===== list = RAW, RELIABLE_STREAM, SECURE_STREAM ======RAW====== client = None server = None ======RELIABLE_STREAM====== client = x.y.PtclClientStack server = x.y.PtclServerStack ======SECURE_STREAM====== client = a.b.secureStreamClientStack server = a.b.secureStreamServerStack
So, the key point is, you have to manually say that your secure stream uses PTCL by explicitly using it in the construction process. Also note that PTCL is wrapping your SecureStream, and not the other way around. That’s because these are factories. Let’s imagine a an echo server over secure stream: listen(EchoServer, 101, “SECURE_STREAM”)
Internally, Playground looks up the factory functions associated with the “SECURE_STREAM” connection type. It locates a.b.secureStreamServerStack and calls it with EchoServer as the top factory. What is returned is a PtclServer factory pointing to a SecureStream factory pointing to an EchoServer factory. This PtclServer factory is associated with port 101.
When a new connection comes in to port 101, the PtclServer factory is looked up, and a new protocol built. The PtclServer factory builds a PtclProtocol and then tells the Higher Factory (i.e., the secure stream factory) to build a SecureStreamProtocol. But that factory, while building the SecureStreamProtocol also tells its Higher Factory (i.e., the echo server) to build an EchoServerProtocol. The echo protocol is returned to the lower factory which connects it to the secure protocol. The secure factory returns the secure protocol to the lower factory which connects it to the ptcl protocol. The ptcl protocol is returned to playground.
As data comes in, it is passed to the ptcl protocol, which passes data up to the secure layer, which passes data up to the echo protocol.