Post

Replies

Boosts

Views

Activity

iOS 14.5 Beta: UDP broadcast not working with "No route to host" error.
After updating my iphone to iOS 14.5 Beta, I am not able to broadcast UDP (using broadcasting IP 255.255.255.255) message on my local network and getting the error message: "No route to host". Here is my code: #import <arpa/inet.h> #import <fcntl.h> #import <ifaddrs.h> #import <netdb.h> #import <net/if.h> #import <sys/socket.h> #import <sys/types.h> (void)sendUDPBroadcast {   int sock = socket(AF_INET, SOCK_DGRAM, 0);   if (sock == -1)   {     NSLog(@"socket create error");     return;   }       if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0)   {     NSLog(@"socket set Nonblock error");     goto CLEAN;   }       int reuseaddr = 1;   if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)) < 0)   {     NSLog(@"socket set SO_REUSEADDR error");     goto CLEAN;   }       int nosigpipe = 1;   if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe)) < 0)   {     NSLog(@"socket set SO_NOSIGPIPE error");     goto CLEAN;   }       int bBroadcast = 1;   if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &bBroadcast, sizeof(bBroadcast)) < 0)   {     NSLog(@"socket set broadcast error");     goto CLEAN;   }       char buffer[] = "Hello world";   struct sockaddr_in sa;   sa.sin_family = AF_INET;   sa.sin_addr.s_addr = inet_addr("255.255.255.255");   sa.sin_port = htons(50000);       int res = sendto(sock, buffer, strlen(buffer), 0, &sa, sizeof(sa));       if (res < 0)   {     NSLog(@"send error:%d msg:%s", errno, strerror(errno));     goto CLEAN;   }     CLEAN:   close(sock); } When I run on an iPhone with iOS 14.5 Beta installed, I get the following error: Line55: send error:65 msg:No route to host Any help is appreciated. Thanks in advance.
15
0
7.1k
Feb ’21