Daniel Stenberg wrote:
>> Right - because send(), unlike write(), doesn't return short.
>
> Nope, that's wrong. See below.
>
>> Why is it desirable to use send()/recv() rather than write()/read()?
>
> Let me quote another piece of the man page:
>
> "The only difference between send() and write(2) is the presence of flags."

Aha. But then send() will also succeed (and possibly return short) on
a socket which was predicted by select() to be writable.

Also interesting:

--8<-- Linux send(2)
       If the message is too long to pass atomically  through the underlying
       protocol, the error EMSGSIZE is returned, and the message is not trans‐
       mitted.
-->8--

This suggests that send() might have closer ties to the system TCP
parameters, while write() is more of an automated thing?


> ... and it also explains why we want to use send() and not write().
> We want the flags.

Which ones?

MSG_DONTWAIT could allow use of send() without select()ing. But if
there is a select(), there's no need for MSG_DONTWAIT.

I saw a note about MSG_NOSIGNAL in your portability notes. Is this
it? If so, why is it important?


Thanks for helping me understand better! :)

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to