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 endconnect only 5% -10% time was thrown.

The exception is one (10065):

  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)  
  • The problem is certainly not crowded, it happens even when only one client is up and running, and when the network traffic is low . / Li>
  • I can see that endconnect is being called immediately after calling BeginConnect , ar.AsyncWaitHandle.WaitOne .

My question is how can I debug this type of error? The server definitely happens at this time.

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

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -