c# tcp connect - Configure socket ACK timeout?

2 Answers

There is mention of a "user timeout" in some IETF RFCs (5482 793) which does what is being asked for.

Some other operating systems support this as a socket option but not Windows unfortunately.

Without this option, the only ways to reduce the time until abort in this scenario would be to reduce the number of retransmission attempts, or reduce the initial RTT.

On Windows the former can be controlled (machine wide..) via netsh/registry: Tcp Max Data Retransmissions.

Is it feasible to just abandon the current connection via your own timeout, and make another if required?

  • The applications would have to establish when the connection is to be abandoned - possibly some "time to live" established at the start of the TCP conversation, based on time of inactivity or effective data rate
  • There would a bit of data overhead due to the retransmits from the old connection
  • The server app may need changed to accept more than one concurrent conection
  • This process should not be repeated indefinately by the client in case the network never achieves quite enough speed for your timeout
in websocket connection

Is there a way to configure the timeout in which a socket expects to receive an ACK for sent data before it decides that the connection has failed?

I'm aware this can be done at the application level as well, but since every packet I send is ACK'd anyway, and I just want to know if my data is received, using additional data at the application level to accomplish the same thing seems wasteful. (Not to mention, my particular application uses per-byte charged cellular links.)

Note: As per my previous question -- What conditions cause NetworkStream.Write to block? -- you cannot rely on .Write throwing an exception in order to determine that data is not being sent properly.