On Mon, 2005-10-31 at 18:14 +0100, Dirk Meyer wrote: > Won't work. In my case I want to send 200k data. This would block, so > we can an exception. But we can send, so we enter this function again, > but not 200k, so we leave again. You need to send in 4k pieces to be sure.
I was under the impression send() will send as much as it can. The docs for send() says: Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. Why is the problem solved with 4k chunks? What if the socket is connected over a slow modem? Sending 4k could block too. If it works as you've described, the problem is not fundamentally fixed. Just hidden because our wire is fast. Instead, if send() will send as much as it can without blocking (which I assume just means moving some chunk of data to the kernel's network buffers) and returns the number of bytes it was able to dispose, it should work properly as it's coded now. Maybe you can write a small test case to expose the problem when you get home, since I'm not able to reproduce it here. Cheers, Jason.
signature.asc
Description: This is a digitally signed message part