[lug] [OT] Threads & Socket Programming

David Morris david at morris-clan.net
Thu Oct 24 17:06:02 MDT 2002


On Thu, Oct 24, 2002 at 05:04:38PM -0600, Tom Tromey wrote:
> >>>>> "David" == David Morris <lists at morris-clan.net> writes:
> 
> David> Everything works fine, except that if I write too many
> David> packets to the socket too fast, I loose data packets (never
> David> received by the client side).
> 
> Are you using UDP?  If so, don't.
> If you're using TCP, then you've found a bug.  TCP is supposed to be
> reliable.  UDP isn't.

I am using TCP.

After a bit of experimenting, I found out what is happening:

Packets to be sent (with send() or write()) are only sent
when the thread is active.  When I do a conditinal wait
(using pthread_cond_wait() until the main application tells
me there is data in the queue), any packets that have not
been sent as of the time I do the wait are not sent until
the next time the thread is activated.

I think what I need is a way to to a blocking wait until the
buffer used by send() is empty....anyone know how exactly
this is done?

--David




More information about the LUG mailing list