[Tutor] Re: Reading text lines from a socket
Donn Cave
donn at drizzle.com
Sun Feb 29 00:21:57 EST 2004
Quoth Bob Ippolito <bob at redivi.com>:
| The real solution is just to use a layer of abstraction, like
| asyncore/medusa, Twisted, etc. Relying on the fact that your operating
| system may or may not allow a socket to act sort of like a file is
| really not something you should do, from Python or otherwise.
|
| socket.makefile is platform specific, at best.
Is it? Do you know of a platform where it doesn't work? I won't
laugh -- I use Python on BeOS. But there, where in fact sockets
can't be treated as files, makefile() works anyway because it makes
a Python class instance that's like a file object, but uses recv()
and send() instead of the read(2) and write(2) system calls that the
file object uses via stdio.
I don't use it myself, but because I just don't like the way stdio
buffering works with devices like pipes and sockets. Haven't noticed
a platform portability problem.
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list