0

Our C# applications targeting .NET 4.0 sends an udp broadcast from time to time to IPAddress.Broadcast. We recently received a log (run on Win 8.1 Pro), which shows up that sending to 255.255.255.255:somePort resulted in a SocketException with ErrorCode 10065 (WSAEHOSTUNREACH).

I'd consider this as non remarkable, if either the network connection is lost or if sending to a specific machine. But at the time of the exception, the network was up and running, even incoming UDP packages could be read from the same socket.

Here's the code being used:

public void Setup(){
  _incoming = new IPEndPoint(IPAddress.Any, IncomingPort);
  _outgoing = new IPEndPoint(IPAddress.Broadcast, OutgoingPort);

  _udpClient = new UdpClient();
  _udpClient.Client.ExclusiveAddressUse = false;
  _udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

  _udpClient.Client.Bind(_incoming);
}

public void Send(byte[] dataToSend)
{
  _udpClient.Send(dataToSend, dataToSend.Length, _outgoing);
}

Now the two questions regarding this issue:

1.) What could cause this behavior?

2.) What scenario do i need to setup to, in order to be able to test the same behavior?

ElGaucho
  • 408
  • 2
  • 14
  • Possibly [this](http://stackoverflow.com/a/21880639/2953335)? – Carl Reid Oct 09 '15 at 11:23
  • The exception was occuring for over 30 minutes - and the machine was up and running for approx. 4 hours before. We tried to restart the machine, the issue was still there. – ElGaucho Oct 09 '15 at 12:07

0 Answers0