Quoting Shachar Shemesh <[EMAIL PROTECTED]>:

> Ori Idan wrote:
>
> > Shachar Shemesh wrote:
> >
> >> Hi all,
> >>
> >> There are two ways of closing a TCP socket. One is to use "close",
> >> and the other is to use "shutdown". The later allows half-closed
> >> sockets (i.e. - one side is closed, the other still open), which is a
> >> bonus. However, the info page for shutdown states that closing the
> >> write part (i.e. - saying you won't send any more data) will discard
> >> any unsent data. This is a problem when using asynchronous mode. The
> >> only workaround that pops to mind is to use fsync, which is blocking
> >> and thus unsuitable.
> >>
> >> Anyone have any idea how to solve this problem? I need an
> >> asynchronous way of knowing when it is ok to call "shutdown" without
> >> losing information sent to the socket.
> >>
> >>                Shachar

man 7 tcp

       SIOCOUTQ
              Returns  the  amount  of unsent data in the socket send queue in
              the passed integer value pointer.  The socket  must  not  be  in
              LISTEN state, otherwise an error (EINVAL) is returned.


U need to know that shutdown is a blocking operation. You need to dissallow
socket lingering. After calling shutdown on socket, move it to some temprorary
queue and close it after few seconds.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to