lkml.org 
[lkml]   [2002]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: socket write(2) after remote shutdown(2) problem ?
From
   From: Stelian Pop <stelian.pop@fr.alcove.com>
Date: Fri, 5 Apr 2002 14:00:55 +0200

As you can see, read() doesn't return any error, just 0 to
indicate end-of-file (seems correct interpretation of remote
shutdown here), but it doesn't report any error from the
precedent write... Bug ?

Race, wait a bit, the reset will arrive.

This is a error state in your code, writing when the server expects no
data. Always remember that when you are trying to judge if
whatever socket operation results is valid or invalid.

Since we find out about the reset asynchronously, this is what
happens.

> But all of this is irrelevant. When a server closes and says "send me
> no more data", this implies that the server told the client it doesn't
> want any more data.

Perfectly valid but only if the 'applicative close' has reached the
other end. If it's still queued in TCP buffers, the client may not
have received yet that close... I thought that this was the only
reason that shutdown() existed at all: flush the buffers preparing
an imminent close...

Not a close "in TCP" but a close "in your apps protocol".
As in:

write(socket_fd, "Ok client I have all your data, lets close now")

See? If the server closes without telling the client that, all
bets are off.

Look, your app is buggy, PERIOD. Once you start to write to a closed
socket, sorry the phase of the moon decides what happens to you. Most
of the time you'll be lucky and see an error.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.059 / U:0.784 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site