No route to host

After updating my Xcode to Version 12.0 (12A7209) and updating my iphone to iOS 14. I am not able to broadcast UDP message on my local network and getting this error message: No route to host . I have got the multicast entitlement from Apple Networking as well. Using this code originally written by Gunter Hager.


I am stuck now and my app has become of no use. Please help!!!
Most problems like this are caused by you not targeting a specific interface on which to broadcast. I’ve posted a snippet of how I do that here. The critical part is the use of IP_BOUND_IF.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
@eskimo Thanks a lot for your prompt reply on the issue.
I followed your post to solve my problem. I made changes to my code and ended up getting Network Unreachable. I have little knowlegde in Darwin framework. Could you please take a look at this and tell me how to modify or add the IP BOUND IF part.
Code Block // Create new socket
    let newSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
    guard newSocket > 0 else { throw ConnectionError.createSocketFailed }
     
    // Enable broadcast on socket
    var broadcastEnable = Int32(1);
    let ret = setsockopt(newSocket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, socklen_t(MemoryLayout<UInt32>.size));
    if ret == -1 {
      debugPrint("Couldn't enable broadcast on socket")
      close(newSocket)
      throw ConnectionError.enableBroadcastFailed
    }
     
    // Bind socket if needed
    if shouldBeBound {
      var saddr = sockaddr(sa_len: 0, sa_family: 0,
                 sa_data: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
      self.address.sin_addr = INADDR_ANY
      memcpy(&saddr, &self.address, MemoryLayout<sockaddr_in>.size)
      self.address.sin_addr = INADDR_BROADCAST
      let isBound = bind(newSocket, &saddr, socklen_t(MemoryLayout<sockaddr_in>.size))
      if isBound == -1 {
        debugPrint("Couldn't bind socket")
        close(newSocket)
        throw ConnectionError.bindSocketFailed
      }
    }


Could you please take a look at this and tell me how to modify or add
the IP_BOUND_IF part.

The snippet from the thread referenced by my original post shows the basics. If you need help beyond that, you should open a DTS tech support incident so I allocate more time to helping you one-on-one.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Hi,
did you manage to resolve this issue?
I have the same problem, using the same code (UDPBroadcastConnection.swift).
If you have a solution please share it.
No route to host
 
 
Q