4

In the below generic scenario:

System.Net.Sockets.TcpClient TC = SomeHowObtained;
System.Net.Sockets.NetworkStream NS = TC.GetStream();

there are 3 timeouts as far as I see:

NS.ReadTimeout // 1
TC.SendTimeout // 2
TC.ReceiveTimeout // 3
NS.WriteTimeout // 4

Is (1) = (3) and (2) = (4) in the sense of behaviour? The documentation does not give a hint.

paul simmons
  • 5,568
  • 13
  • 51
  • 78

1 Answers1

8

Yes that's it !

If you take a look at the implementation of ReadTimeout and WriteTimeout properties in NetworkStream class, you will find out that they are just wrappers arround Socket ReceiveTimeout and SendTimeout properties (and TcpClient ReceiveTimeout and SendTimeout properties are wrappers arround the Socket properties of the same name).

Meaning that in the end you are getting or setting the ReceiveTimeout and SendTimeout property of the Socket via NS and TC objects, no matter what.

In a nutshell :

NS.ReadTimeout == TC.ReceiveTimeout == Socket.ReceiveTimeout
MS.WriteTimeout == TC.SendTimeout == Socket.SendTimeout
darkey
  • 3,672
  • 3
  • 29
  • 50