I am using GCDAsyncUdpSocket for broadcasting UDP packets for searching my NAS devices.
Below is the code snippet for sending and receiving UDP packets
NSString *broadCastAddress = @"255.255.255.255";
NSInteger udpPort = 8097;
GCDAsyncUdpSocket *gcdAsyncUdpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:selfdelegateQueue:dispatch_get_main_queue()];
[gcdAsyncUdpSocket bindToPort:udpPort error:&error];
[gcdAsyncUdpSocket setPreferIPv4];
NSData *data = @“Hi there”; // Sample data
[gcdAsyncUdpSocket enableBroadcast:YES error:&error];
[gcdAsyncUdpSocket beginReceiving:&error];
[gcdAsyncUdpSocket sendData:data toHost:broadCastAddress port:udpPort withTimeout:-1 tag:1];
The above code can send packets through only single Network interface i.e either Wifi or Ethernet or Thunderbolt, the thing is i want to broadcast through all of the available Network Interfaces. (Ethernet, WiFi, Thunderbolt etc.).
Is there any way i can broadcast via all the available Network Interfaces (Ethernet, WiFi, Thunderbolt etc.) at the same time and using the same port.
Any help is appreciated, thanks in advance.