Subprocess with a Python Session?
Hendrik van Rooyen
mail at microcorp.co.za
Sat Dec 9 02:53:54 EST 2006
"Paul Boddie" <paul at boddie.org.uk> wrote:
> Fredrik Lundh wrote:
> > Paul Boddie wrote:
> >
> > > This is one of the more reliable methods since upon receiving a packet
> > > "delimiter" the receiver knows that the data is complete.
> >
> > and for people who want <strong>RELIABLE</strong> and not just "at least
> > not entirely unreliable", there's always:
> >
> > http://cr.yp.to/proto/netstrings.txt
>
> That's why I hedged my bets and put "one of the more" rather than "the
> most" in that sentence. ;-) I've been using netstrings myself, although
> I didn't know that they had that particular name.
>
> > (if you control both ends, there's hardly ever any reason not to use
> > netstrings. they're trivial to generate from Python, and pretty simple
> > to parse.).
>
> Indeed.
I was not aware that putting the length in front of a data packet had been
blessed with the name "netstring".
It is almost obligatory to do something like this if you are using raw sockets
as otherwise you never know where you are.
What I tend to do is more complex and probably also has a name that I am unaware
of - I "frame" packets between tildes - 0x7e - the SDLC/HDLC flag character -
this requires me to escape tildes, and my "escape" char, to prevent them
occurring in the message - I use the ordinary forward slash as the escape char,
and alter the poison chars by exclusive oring them with 0xff to invert - after
adding at least a bcc formed by the xor of all the chars in the package, (before
the escaping), and where its important, I use message numbers too... - but
then - I am paranoid... And yes I once wrote some x25 type stuff in z80
assembler... :-)
- Hendrik
More information about the Python-list
mailing list