[Tutor] reading an input stream

James Chapman james at uplinkzero.com
Thu Jan 7 12:07:03 EST 2016


​Ah yes, OK.

STX and ETX are control characters ​as you've probably worked out. Are
there other control characters? Ideally you should have some kind of
message header with the size of the data to be received. You'd then know
how big the receiving buffer needs to be rather than having a fixed and
presumably maximum size of incoming message buffer size.

>From an architectural POV I'd have a few listener threads that upon receipt
would spawn (or take from a pool is a better approach) a worker thread to
process the received data.

Some python snippets that may/may not be of help in my github repo here
<https://github.com/James-Chapman/python-code-snippets>. There are
unfortunately no raw socket code snippets in there.

I'd be keen to see the raw socket data (stripped of any actual xml content
and anything other identifying indicators) as I'm assuming there's more
than just...

\x02
<?xml version="1.0" encoding="utf-8"?>
<foo>
  <bar></bar>
</foo>
\x03


-J


More information about the Tutor mailing list