Unix Stream socket -- "send()" for large amount of data
- From: Alan McKenney <alan_mckenney1@xxxxxxxxx>
- Date: Fri, 21 Mar 2008 03:56:12 -0700 (PDT)
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'treally 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.)
.
- Follow-Ups:
- Re: Unix Stream socket -- "send()" for large amount of data
- From: David Schwartz
- Re: Unix Stream socket -- "send()" for large amount of data
- Prev by Date: Re: Unexpected Output when reading a files using read()
- Next by Date: Re: pid_t data type
- Previous by thread: Unexpected Output when reading a files using read()
- Next by thread: Re: Unix Stream socket -- "send()" for large amount of data
- Index(es):
Relevant Pages
|