Problems with read_eager and Telnet

Robi roberto.inzerillo at gmail.com
Mon Feb 28 17:50:55 CET 2011


> Telnet sends two kinds of data over the same channel (a simple TCP
> stream).  It sends the bytes you actually see in your terminal and it
> sends control commands that do things like turn echo on/off and
> negotiate what terminal type to use.  Each time telnetlib reads from
> the socket it puts the control stuff in one bucket and stores the
> plain text in a buffer to return from all the read_* commands.
>
> read_eager() returns the plain text that has already been read from
> the socket.  That might be a partial line.  It won't try to read from
> the socket to get a full line.  That's why it is fast, because it
> never does I/O.
>
> -Jack

Ok, that's a start (I'm reading RFC 854 in the meanwhile). Still that
doesn't help me much (sorry, I know it's me, not you).

You mean read_eager() doesn't wait until it gets a complete reading of
a line, instead it reads what's on the socket (even if it's to quick
and there's till nothing) and let's the python script running anyway,
right?
Then with the subsequent read_eager() it will read (if there's
something more on the socket in the meanwhile) the previous data bits
and maybe the new ones too (a new line of data) into a single data
chunk. Is that why I get sometimes repeated empty lines followed by
many consequent lines all together out of a single read_eager() call?



More information about the Python-list mailing list