Re: there's a socket.sendall(), so why no socket.recvall()?

2005-01-16 Thread Roger Binns
 there's a socket.sendall(), so why no socket.recvall()?

BTW socket.sendall() doesn't actually work for large amounts
of data on Windows 2000 and probably other versions of
Windows as well.  Eg if you supply a 1MB buffer then you get
an exception based on some internal Windows error code.
I haven't experimented on Unix yet to see if it has the same
issue.

The workaround is to write a wrapper that really does send
everything.

Roger 


-- 
http://mail.python.org/mailman/listinfo/python-list


there's a socket.sendall(), so why no socket.recvall()?

2005-01-08 Thread Irmen de Jong
Subject says it all;
there's a socket.sendall(), so why no socket.recvall()?
I know that I can use the MSG_WAITALL flag with recv(),
but this is not implemented on all platforms, most
notably windows.
--Iremn
--
http://mail.python.org/mailman/listinfo/python-list


RE: there's a socket.sendall(), so why no socket.recvall()?

2005-01-08 Thread Robert Brewer
Irmen de Jong wrote:
 Subject says it all;
 there's a socket.sendall(), so why no socket.recvall()?

Good question! Something like:

# Receive reply.
data = []
while True:
try:
chunk = conn.recv(8192)
except Exception, x:
if x.args[0] != 10035:
raise x
else:
if chunk == '':
break
data.append(chunk)

If you call .makefile() and then .read() the _fileobject, you get the
same behavior (only better). Adding recvall would just duplicate that, I
think. But that's desirable IMO.


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: there's a socket.sendall(), so why no socket.recvall()?

2005-01-08 Thread Irmen de Jong
Robert Brewer wrote:
Irmen de Jong wrote:
Subject says it all;
there's a socket.sendall(), so why no socket.recvall()?

[...]
If you call .makefile() and then .read() the _fileobject, you get the
same behavior (only better). Adding recvall would just duplicate that, I
think. But that's desirable IMO.
Hm, I didn't consider makefile(). But I'm not sure if that
works in all cases. Until now, I've been using a loop rather
like the one you posted.
But, as I pointed out earlier, there is the MSG_WAITALL option
on various platforms (Linux for instance).
So instead of sticking it in an explicitly programmed loop
in Python, or using an extension module such as this one:
http://mail.python.org/pipermail/python-list/2003-January/143051.html
, I'd rather have a recvall method on the socket object that
essentially uses MSG_WAITALL if available, and uses a
loop construction if not.
I may even write a patch for socketmodule.c right now :-D
--Irmen de Jong
--
http://mail.python.org/mailman/listinfo/python-list