Re: Socket weirdness



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

.



Relevant Pages

  • Re: Socket weirdness
    ... understand yet is why RST is not set in the header of outgoing data ... if the server does a send after Receive is closed? ... TCP connection can be "half-open", meaning one directon is closed, ... "TCP provides the ability for one end of a connection to terminate its output, while still receiving data from the other end. ...
    (microsoft.public.dotnet.framework)
  • Re: Question regd timestamp option
    ... > RST Following this RST, the client comes back in lets say around ... Now if you open a second connection, while things are still OK, do you see the ... connections to the server? ...
    (freebsd-net)
  • Re: Something Not going with my LDAP using SSL
    ... closes the connection by sending a RST to the server. ... I suspect this is not a certificate problem - a lot of negotiation has ...
    (comp.lang.ruby)
  • Re: TCP RST and why that might happen
    ... >> Anyone have a clue as to why a connection I create with a server would cause ... >> a TCP RST to be sent from the server? ...
    (comp.os.linux.development.system)
  • Re: weird scans from port 80
    ... the attack to hide their own identity. ... >> It specifies in all details when to send RST and when not to. ... requiring a reset in response to an unexpected TCP packet? ... So if the connection is in the CLOSED state (which is ...
    (comp.os.linux.security)