[Tutor] Reading text lines from a socket
pythontutor at venix.com
Sat Feb 28 18:34:33 EST 2004
Sockets deal with packetized data. The network protocols do not guarantee
keeping the data in line oriented chunks - even if the data starts out that way.
You need to deal with extracting lines from chunks. So long as the connection is
working properly, this is easy. The challenge occurs when the remainder of a line
never gets delivered. The best strategy depends upon the details of what you are
Sandip Bhattacharya wrote:
> The socket objects only allow data to be read in by chunks (recv()). How
> do I manage to read in data one line at a time where a line is defined
> as a lf/cr-lf terminated test string?
> In other words how can one write their own clients for reading/writing
> data for text based protocols like smtp?
1 Court Street, Suite 378
Lebanon, NH 03766-1358
More information about the Tutor