Reading line-by-line on a socket
xxdigitalhellxx at hotmail.com
Thu Mar 13 22:12:21 CET 2003
> 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?
> The reason this doesn't work for me is because I would like select() to
> still be able to detect that there is data waiting to be read from the
> socket. If all else fails I'll just have to do a loop through the
> incoming queue after my socket has data to be read.
> In short, I want a readline() for a socket.
> Any suggestions?
Sorry for the stupid quesetion...
I tried makefile()/readline() in Pythonwin before I messages this group
and it crashed Pythonwin so I assumed that it wasn't possible this way.
After trying it in the interpreter run from the command line it works fine:
s = socket.socket(AF_INET, SOCK_STREAM)
x = s.makefile("rb")
s.write ("HEAD ...")
More information about the Python-list