Re: Socket weirdness



In article news:uDcHHNR3GHA.3828@xxxxxxxxxxxxxxxxxxxx, Goran Sliskovic
wrote:
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.

Er, it's "half-closed". :-,)

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 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).

Nice.
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.

.



Relevant Pages

  • Re: [2.6.24.3][net] bug: TCP 3rd handshake abnormal timeouts
    ... server via TCP and non-persistent connections and all application level ... "Sometimes" when establishing a TCP connection to the server, ... Here is a simplified version of what _both_ the server and the client ...
    (Linux-Kernel)
  • Re: [2.6.24.3][net] bug: TCP 3rd handshake abnormal timeouts
    ... server via TCP and non-persistent connections and all application level ... "Sometimes" when establishing a TCP connection to the server, ... Here is a simplified version of what _both_ the server and the client ...
    (Linux-Kernel)
  • [2.6.24.3][net] bug: TCP 3rd handshake abnormal timeouts
    ... The case is about a bunch of web servers accessing a MySQL database server via TCP and non-persistent connections and all application level errors have been excluded. ... "Sometimes" when establishing a TCP connection to the server, we are seeing a 3000ms delay before the connection if effectively made. ... Here is a simplified version of what _both_ the server and the client see. ...
    (Linux-Kernel)
  • Re: Dropped Sessions Pervasive v7
    ... Pervasive is a slave to the TCP stack -- if the TCP connection is lost, ... Looking in to the PVSW.LOG file on a client machine ... > connections to the database server being dropped. ...
    (comp.databases.btrieve)
  • Re: NAT and keepaliveopen connection over TCP
    ... sent after 10 minutes of inactivity on the TCP connection. ... There's no minimum set time how long a NAT router should ... time-out inactive connections at the server. ...
    (microsoft.public.win32.programmer.networks)

Loading