reading sockets
Ken Mugrage
kmugrageREMOVE at hotmail.com
Wed Jul 4 19:30:45 EDT 2001
Sorry for the newbie question, but I'm just learning python and trying to
write a small program that uses sockets.
Basically, I wam to emulate the perl behavior of reading the response from
the server one line at a time.
In perl, I would do something like
while(<SOCKET>) {
print $_;
}
and it would print everything as it is sent, one line at a time.
In Python, I have something like
while 1:
data = mysocket.recv(1024)
print data
which of course print everything in 1024 byte blocks.
I tried using string.split( data, "\n") but the results are inaccurate,
since the end of data may be in the middle of a line.
Any suggestions would be greatly appreciated.
More information about the Python-list
mailing list