Re: Socket weirdness
- From: Goran Sliskovic <gsliskov@xxxxxxxxx>
- Date: Thu, 21 Sep 2006 02:17:07 +0200
William Stacey [MVP] wrote:
....
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.
Shutdown.Receive is meaningfull only to OS, there is no data exchange 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).
Regards,
Goran
.
- Follow-Ups:
- Re: Socket weirdness
- From: Alan J. McFarlane
- Re: Socket weirdness
- 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]
- Socket weirdness
- Prev by Date: Re: Dynamically instance a class
- Next by Date: Re: Socket weirdness
- Previous by thread: Re: Socket weirdness
- Next by thread: Re: Socket weirdness
- Index(es):
Relevant Pages
|