UDPBroadcastConnection
UDPBroadcastConnection copied to clipboard
UDP broadcast doesn't work with iOS 14
When trying to send data to all available devices using udp broadcast, it gives me this log message:
“Error: sendingMessageFailed(code: 22)\n”]
“Closing UDP socket”]
I updated the library. Could you please check if the issue still persists? For me it always worked with iOS 14.
This should help : https://developer.apple.com/forums/thread/662082
I experience also the similar issue on iOS 14 devices however already on binding:
let isBound = bind(newSocket, &saddr, socklen_t(MemoryLayout<sockaddr_in>.size))
this value is "almost" always -1 on iPad, however it works almost always on iPhone... Both devices are running iOS 14.4/iPadOS 14.4
Can you try to add the NSLocalNetworkUsageDescription key to your Info.plist and tell us if it makes a difference ?
Yes, I tried it already, unfortunately there is no difference. By the way, thanks for the link above. There are some other suggestions how to realize the UDP connections, especially using bonjour. But in our case we have app implementations for Windows and Android and need to broadcast "pure" UDP messages through the network. I've contacted Apple support because of Multicast networking entitlement and am waiting for the reply... I'm almost sure, that I do not need, because the Implementation of Gunter works still on iPhone, only iPad experiences issues...
Oh, I remember what I've done to have two iPad communicates fine : just send one packet (and you'll see the system alert about local network access)
hm, for sending a package I need a socket, but the binding fails with -1:
let isBound = bind(newSocket, &saddr, socklen_t(MemoryLayout<sockaddr_in>.size))
or do I misunderstand something? Thank for your previous prompt reply ;-)
hey guys, thanks for your help. It turned out, that my problem was port 15000... after changing the port, it started working! after rebooting the ipad port 15000 got also released and i can use it again.
Nice catch, maybe an indication about changing port in the debugPrint and in comment of ConnectionError.bindSocketFailed should help next users having this issue
https://github.com/gunterhager/UDPBroadcastConnection/blob/master/UDPBroadcast/UDPBroadcastConnection.swift#L173
https://github.com/gunterhager/UDPBroadcastConnection/blob/2303b9178f2cdb35e61edbeacbb0f9df437c1266/UDPBroadcast/UDPBroadcastConnectionError.swift#L18