[Python-Dev] noreply@sourceforge.net: [Python-bugs-list] [Bug #111620] lots of use of send() without verifyi ng amount of data sent.
Thomas Wouters
thomas@xs4all.net
Fri, 11 Aug 2000 16:43:49 +0200
On Fri, Aug 11, 2000 at 10:33:35AM -0400, Andrew Kuchling wrote:
> On Fri, Aug 11, 2000 at 04:21:09PM +0200, Thomas Wouters wrote:
> >Someone set the patch to 'rejected' and tell the submittor that 'send'
> >doesn't return the number of bytes written ;-P
> What about reviving the idea of raising an exception, then?
static PyObject *
PySocketSock_send(PySocketSockObject *s, PyObject *args)
{
char *buf;
int len, n, flags = 0;
if (!PyArg_ParseTuple(args, "s#|i:send", &buf, &len, &flags))
return NULL;
Py_BEGIN_ALLOW_THREADS
n = send(s->sock_fd, buf, len, flags);
Py_END_ALLOW_THREADS
if (n < 0)
return PySocket_Err();
return PyInt_FromLong((long)n);
}
(PySocket_Err() creates an error.)
--
Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!