High performance IO on non-blocking sockets

Richie Hindle richie at entrian.com
Fri Mar 14 08:42:05 EST 2003


[Troels]
>   sent = self.socket.send(self.data)
>   self.data = self.data[sent:]
> 
> This approach is bad [...]

>From http://www.python.org/doc/current/lib/socket-objects.html :

------------------------------- snip snip -------------------------------

7.2.1 Socket Objects

[...]

sendall( string[, flags]) 

Send data to the socket. The socket must be connected to a remote socket.
The optional flags argument has the same meaning as for recv() above.
Unlike send(), this method continues to send data from string until either
all data has been sent or an error occurs. None is returned on success. On
error, an exception is raised, and there is no way to determine how much
data, if any, was successfully sent. 

------------------------------- snip snip -------------------------------

Nothing springs to mind for the recv case (but the problems are lesser in
that case).

-- 
Richie Hindle
richie at entrian.com





More information about the Python-list mailing list