问题
The flag MSG_WAITALL
can be used for recv
, which requests recv
to block until the full request is satisfied. That means recv
will not return until as much data as requested (specified by the argument len
) has been received, unless an error occurs or the connection has been closed.
Why doesn't such a flag apply to send
too? I think it would be very useful for sending (send
doesn't return until ALL the bytes the caller wants to send has been handed to TCP send buffer)
回答1:
It would be redundant. You can always put the socket into blocking mode, if it isn't already, in which case send()
blocks until all the data has been transferred.
来源:https://stackoverflow.com/questions/44240934/why-is-there-no-flag-like-msg-waitall-for-send