I was testing socket timeout and noticed that it didn’t seem to honor the timeout value I set.
As a test I got to try to connect to every IP on my network, and set the socket send and rec timeout to 100ms.
The code snippet:
IPAddress host = IPAddress.Parse(ip);
IPEndPoint hostep = new IPEndPoint(host, port);
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
sock.ReceiveTimeout = receiveTimeout;
sock.SendTimeout = sendTimeout;
sock.Connect(hostep);
The exception is thrown in the last line, I have the code in a try/catch block.
As you can see the times are all over the place, and some are over 100s:
Is this a know issue?
Thanks
Guy
Ping took took : 42997ms GC = 40872
Ping took took : 46611ms GC = 40872
Ping took took : 307ms GC = 38472
Ping took took : 412ms GC = 38472
Ping took took : 307ms GC = 38472
Ping took took : 1553ms GC = 38472
Ping took took : 444ms GC = 38472
Ping took took : 50275ms GC = 40872
Ping took took : 307ms GC = 38472
Ping took took : 105265ms GC = 40872
Ping took took : 422ms GC = 38460
Ping took took : 46491ms GC = 40860
Ping took took : 307ms GC = 38460
Ping took took : 308ms GC = 38460
Ping took took : 46675ms GC = 40860
Ping took took : 47209ms GC = 40860
Ping took took : 50669ms GC = 40860
Ping took took : 106176ms GC = 40860
Ping took took : 47192ms GC = 40860