readlines() on a socket
Skip Montanaro
skip at pobox.com
Wed Oct 24 00:52:59 EDT 2001
More information about the Python-list mailing list
Wed Oct 24 00:52:59 EDT 2001
- Previous message (by thread): How to set papersize for printer in win32
- Next message (by thread): readlines() on a socket
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Gregory> I'd like to be able to do
Gregory> s = socket.socket(...)
Gregory> s = socket.connect(....)
Gregory> for l in s.readlines():
Gregory> # process line l
Gregory> but sockets don't support readline(), or readlines(), or
Gregory> anything similar that I can see.
Socket objects have a makefile() method that will return a file object.
s = socket.socket(...)
socket.connect(....)
f = s.makefile()
for l in f.readlines():
process_lines()
(Also, note that you should not assign the result of the connect method. I
believe it simply returns None.)
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
- Previous message (by thread): How to set papersize for printer in win32
- Next message (by thread): readlines() on a socket
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list