> On Mar 25, 2015, at 1:35 AM, Burak Arslan <[email protected]> wrote:
> 
> Hello All,
> 
> I'm using twisted for implementing a custom protocol via SSL.
> 
> I've been wondering though, is there an easy way of counting the number
> of bytes that go in and out of the socket, including SSL overhead?

Well, "easy" is relative :).

Internally in Twisted, TLS is implemented as a wrapper protocol that sits on a 
low-level transport, and acts as a transport for your protocol, and a protocol 
for the TCP (or other stream-based) transport.  Older APIs like connectSSL, 
listenSSL, and .startTLS on a protocol somewhat obscure this, and there's no 
nice way to expose it.

However, there is a ticket in progress: 
https://twistedmatrix.com/trac/ticket/5642 
<https://twistedmatrix.com/trac/ticket/5642> which has some code that 
demonstrates how to make the TLS stuff "purely" a wrapper all the way from the 
endpoint to your application code.

What you need to do is write your own wrapper protocol and interpose it below 
the TLS transport (act as the transport for the TLS protocol, and the protocol 
for the TCP transport).

If it is not obvious how to do this from the documentation for 
twisted.protocols.policies.ProtocolWrapper and the code in the aforementioned 
ticket, I (or someone else) can elaborate.

-g
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to