Reading line-by-line on a socket
sismex01 at hebmex.com
sismex01 at hebmex.com
Thu Mar 13 16:04:01 EST 2003
> From: sik0fewl [mailto:xxdigitalhellxx at hotmail.com]
> Sent: Thursday, March 13, 2003 2:59 PM
>
> Hey,
>
> Is there any way to read line by line on a socket, without having to
> recv() a chunk and the keep it in some sort of queue to
> retrieve later?
>
Yes. Let's say that "sock" is your receiving socket,
ready to do a recv. You can do this:
>>> reader = sock.makefile("r")
and now you have a file-like object in "reader", which you
can apply readline() to.
hth
-gustavo
More information about the Python-list
mailing list