Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send UDP broadcast packets through all interfaces in Objective-C / OS X 10.8 (DHCP)
    primarykey
    data
    text
    <p>I am creating a small utillity which has to serve an IP address and parameters over BOOTP on my MacBook Pro.</p> <p>I have used the AsyncUdpSocket library from GitHub (thanks RobbieHanson) and when I have my machine configured with just the wired ethernet connected (Airport Off) then it works. However, as soon as I enable my Wifi as well, all the broadcast replys go down the Wifi interface instead. This causes the wired clients to get no answer.</p> <p><strong>Initialise/Receive Code:</strong></p> <pre><code>if (![socket bindToAddress:@"0.0.0.0" port:67 error:&amp;err]) NSLog(@"Error: unable to bind (%@)", [err localizedDescription]); [socket enableBroadcast:YES error:&amp;err]; [socket receiveWithTimeout:-1 tag:0]; </code></pre> <p><strong>Send Code:</strong></p> <pre><code>[sock sendData:packetData toHost:@"255.255.255.255" port:68 withTimeout:-1 tag:0]; </code></pre> <p>I am sure there must be a way to do this, but this is my first OS X program and I am struggling to master my google-search etiquette to suit the frameworks :)</p> <p><strong>UPDATE</strong></p> <p>I have messed about with my code tonight and inspected what the AsyncUdpSocket is doing when I am calling it. Essentially I have the following situation; if I call <code>bindToAddress</code> and supply <code>10.0.0.1</code> (the address assigned to my ETH NIC) then I neither receive any packets NOR can I send them. However, if I pass <code>nil</code> into the method then I can send a message AND receive the broadcasts - the downside being that the sending goes out over my WIFI NIC (default route)</p> <p>In the background - the <code>AsyncUdpSocket</code> library is calling <code>CFSocketSetAddress</code> with either IFADDR_ANY when supplied a nil value OR a populated IFADDR struct of 10.0.0.1 if that is supplied. No errors are thrown and so it should be expected to work.</p> <p>Any ideas? I am going up the wall and just want this solved. I really like the async nature of teh library so I don't want to throw it out.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload