Purging socket send buffers

Purging socket send buffers

Post by Marku » Fri, 22 Jun 2007 03:05:57



Hi,

assume you are trying to send data to a remote host over a TCP-
socket.  Suddenly the remote host blocks for some unspecified time,
and your socket send buffer fills up until a write call would block.
Is there a way to get rid of the buffered data once it is in the
socket send buffer managed by the kernel?

In my specific case messages become stale very quickly, and it may
have drastic consequences if they get delivered at all if too late.
If the system detects that a remote host is too slow or screwed up, it
should do its best to get rid of any message still under its control.
It would be great if there is a system call that I can use to purge
data buffered in socket send buffers.

Regards,
Markus

 
 
 

Purging socket send buffers

Post by Robert Harri » Fri, 22 Jun 2007 04:17:06



> Hi,

> assume you are trying to send data to a remote host over a TCP-
> socket.  Suddenly the remote host blocks for some unspecified time,
> and your socket send buffer fills up until a write call would block.
> Is there a way to get rid of the buffered data once it is in the
> socket send buffer managed by the kernel?

> In my specific case messages become stale very quickly, and it may
> have drastic consequences if they get delivered at all if too late.
> If the system detects that a remote host is too slow or screwed up, it
> should do its best to get rid of any message still under its control.
> It would be great if there is a system call that I can use to purge
> data buffered in socket send buffers.

> Regards,
> Markus

If you were to do that, then the remote host would never recover because
TCP is a stream, not a sequence of messages. So shutdown() is probably
what you are after.

Robert