> As for replacing the protocol but keeping the transport, what would
> be the semantics of that?
The protocol is not really replaced, it's wrapped.
Before:
SocketTransport <- UserProtocol
After:
SocketTransport <- (asyncio.sslproto.SSLProtocol
<- asyncio.sslproto._SSLProtocolTransport) <- UserProtocol
That way, the same SocketTransport (but it could be something else, e.g. a pipe transport) is always bound to the event loop; we simply insert a processing layer in the chain between the original transport and the final protocol. There are two distinct objects so that the SocketTransport sees a protocol and the UserProtocol sees a transport; but those two objects work hand in hand. |