c# - Sporadic TCP connection failures (WSAEHOSTUNREACH) -
On the local Gigabit network, I have an application using the same TCP server and several clients. Every customer pings the server in every 30 seconds, opening a TCP connection, sending it a message and closing it.
The server is set up using SocketAsyncEventArgs
The relevant section of the client code:
using (TcpClient client = new) TcpClient ()) {IAsyncResult AR = client.BeginConnect (address, port, blank, blank); If (! Ar.AyncWaitHandle.WaitOne (timeout)) {new application extension ("Waiting for time to know" + address); } Client.EndConnect (AR); // Exception 5% -10% time is thrown. // Send message and get feedback ...}
Something works fine except on some machines, with an exception The exception is one (10065): My question is how can I debug this type of error? The server definitely happens at this time. endconnect only 5% -10% time was thrown.
System.Net.Sockets.SocketException (0x80004005): System.Net.Sockets on System.Net.Sockets.Socket.EndConnect A socket operation was attempted on an unreadable host at 192.168.XXX.XXX:XXXX. TcpClient.EndConnect (IAsyncResult asyncResult)
endconnect
is being called immediately after calling BeginConnect
, ar.AsyncWaitHandle.WaitOne
.
The problem is that the windows are related to sleep mode. Sometimes these exceptions arise when the machine was sleeping.
Disabling the experiment as mentioned in the blue mode has taken care of this problem.
Still, I'm not sure why I was getting SocketExceptions in this matter. I could understand that the timer did not fire at all, but not sure why the connection failed.
Comments
Post a Comment