Re: Socket weirdness
- From: "Alan J. McFarlane" <alanjmcf@xxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Sep 2006 19:53:48 +0100
In article news:uDcHHNR3GHA.3828@xxxxxxxxxxxxxxxxxxxx, Goran Sliskovic
wrote:
William Stacey [MVP] wrote:Er, it's "half-closed". :-,)
...
until the 3rd send depending on speed, etc. Thing I don't
understand yet is why RST is not set in the header of outgoing data
if the server does a send after Receive is closed? Or why the
server even lets you do a send after a Shutdown.Receive if
ultimately it forces both sides of the client down anyway?
Server cannot send RST on send after shutdown on its receive part
because it would violate the TCP standard. After you shutdown receive,
sends are legal. Even more, this is part of graceful close handshake.
TCP connection can be "half-open", meaning one directon is closed,
other is still open.
I'll quote from Stevens, TCP/IP Illustrated Volume 1. Section 18.5:
"TCP provides the ability for one end of a connection to terminate its output, while still receiving data from the other end. This is called _half-close_. Few applications take advantage of this capability [...]."
And in section 18.7:
"A TCP connection is said to be _half-open_ if one end has closed or aborted the connection without the knowledge of the other end. Thsi can happen any time one of the two hosts crashes. As long as there's no attempt to transfer data across a half-open connection, the end that's still up won't detect that the other end has crashed."
Shutdown.Receive is meaningfull only to OS, there is no data exchangeNice.
when it is executes. Usually, you would call Shutdown.Receive when you
receive 0 from Socket.Recv, meaning the other part has closed it's
outgoing side. You are still allowed to send until you do
Shutdown.Send. Probably intention with Shutdown.Receive was to
signal OS that you don't expect any data to come int so OS can
release resources (buffers) and spare some memory.
The problem when you do Shutdown.Recv is what TCP stack should do when
it receives data on this connection anyway (this would be simptom of
application protocol error)? It has 3 choices:
a) ignore
b) ACK
c) RST
If it ignores data, this will lead to retransmissions and eventual
timeout on other side and connection close.
If it ACKs, it will trick application on other side which will assume
it was received by other side leading to bad consequences (not an
option)
If it sends RST it will force close on other side much sooner.
So, call it only when other end has closed its outging side or you
abandon connection (followed by close).
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.
.
- References:
- Socket weirdness
- From: William Stacey [MVP]
- Re: Socket weirdness
- From: Dave Sexton
- Re: Socket weirdness
- From: William Stacey [MVP]
- Re: Socket weirdness
- From: Dave Sexton
- Re: Socket weirdness
- From: William Stacey [MVP]
- Re: Socket weirdness
- From: Alan J. McFarlane
- Re: Socket weirdness
- From: Dave Sexton
- Re: Socket weirdness
- From: William Stacey [MVP]
- Re: Socket weirdness
- From: Goran Sliskovic
- Socket weirdness
- Prev by Date: Re: Exclude a project from a multi-project solution build
- Next by Date: Re: Socket weirdness
- Previous by thread: Re: Socket weirdness
- Next by thread: Re: Socket weirdness
- Index(es):
Relevant Pages
|
Loading