Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to clear send Q in multi-thread socket apps

301 views
Skip to first unread message

Wu, Simon [WDLN2:2X38:EXCH]

unread,
Dec 12, 2002, 4:14:21 PM12/12/02
to
Hello,

I am writing a client/server based multi-thread application on red had
linux 7.1.

With each new client connection, the server would create a new thread,
giving each new connection a new file description. The server keeps
sending (write to each fd) some info to the client. However, if one or
more clients would stop reading the info from server, after some time,
the server side's SEND-Q build up (checked with "netstat -ap' on server
side). When the Q is 65532, the server cannot send any stuff to any
client any more.

Is there any way to clear the the SEND-Q before the server write to the
client? I have control to server but not client. And I'd like to keep
the multi-thread model.

Thanks for your help.


Simon

Kevin Easton

unread,
Dec 13, 2002, 3:11:39 AM12/13/02
to

No, that data is sitting there because the client hasn't read it. The
usual way to handle this is to use non-blocking writes, and if the write
returns EAGAIN, that means that the sendq is full and the data couldn't
be written right now.

You can then handle this in two ways - either implement your own, larger
send queue in your server, and when a write returns EAGAIN add it to
that queue, or you can just consider the client stalled and drop it's
connection when it's kernel sendq has filled.

- Kevin.

0 new messages