Unix Stream socket -- "send()" for large amount of data



I'm working on an application where one thread ("producer")
will be adding data to a buffer and another ("consumer")
will be sending it to a stream socket via "send()" as fast
as the socket will take it.

Is it better for the consumer to do a single "send()"
call each time with all the (un-consumed) data in the
buffer?

Or is it better to pass no more than some
"max_send_size" bytes with each call?
(If the system buffer has more than "max_send_size"
bytes available, this would mean more calls to
send().)

From the point of view of my application, it doesn't
really make a difference, except that a single "send()"
call with everything is somewhat simpler to code.
So if there's not much advantage to sending smaller chunks,
I'd go with the "send everything" approach.

(In either case, of course, I will use the value returned
by "send()" to tell how many bytes were actually
sent.)
.



Relevant Pages