diff --git a/CoAP.NET/Channel/UDPChannel.cs b/CoAP.NET/Channel/UDPChannel.cs index e4fdb03..9feae33 100644 --- a/CoAP.NET/Channel/UDPChannel.cs +++ b/CoAP.NET/Channel/UDPChannel.cs @@ -294,13 +294,24 @@ private UDPSocket SetupUDPSocket(AddressFamily addressFamily, Int32 bufferSize) { UDPSocket socket = NewUDPSocket(addressFamily, bufferSize); + try + { + socket.Socket.EnableBroadcast = true; + socket.Socket.ExclusiveAddressUse = false; + socket.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); + } + catch (Exception) + { + // ignore + } + // do not throw SocketError.ConnectionReset by ignoring ICMP Port Unreachable const Int32 SIO_UDP_CONNRESET = -1744830452; try { socket.Socket.IOControl(SIO_UDP_CONNRESET, new Byte[] { 0 }, null); } - catch (Exception e) + catch (Exception) { // ignore }