I have tried the following cases and used a stopwatch to mesaure the actual time it takes for the socket to receive. Note that the timeouts are in miliseconds.
Dim NextClient As New TcpClient
NextClient.ReceiveTimeout = 1 //Case 1
NextClient.Client.ReceiveTimeout = 1 //Case 2
Dim ns As Net.Sockets.NetworkStream = client.GetStream()
ns.ReadTimeout = 1 //Case 3
Dim sw As New Stopwatch
sw.Start()
ns.Read(gbytes, 0, 5997)
sw.Stop()
BTW, ns.CanTimeout returns true. Also, I am not really expecting a 1 ms precision and it is only for testing purposes. I have actually started with 500 ms but first wanted to test with this.
In all cases and their combinations, even though the I have measured 100+ miliseconds each time with the stopwatch, I receive the data with no exceptions. If I intentionally delay the response over few seconds, however, I can get the exception. But even my ping / 2 to the server is much more than 1 ms.
Oddly, if I set the timeout to 1000 ms and the server response takes about 1020 ms the exception is triggered.
So, is there a minimum value or something else?