I am updating a universal app for release on iOS 17+ devices using Xcode15.2 and Solar2d v3708. The last release was 7 years ago.
The app connects to the local network and used a custom UDP protocol to connect to and control specific hardware devices. The protocol involves transmitting and receiving both broadcast and unicast messages to/from IPV4 capable proprietary devices on the local network.
When I run the app in the Solar2d simulator and when I run the current version installed from the App store on my iPad, communications work well.
When I build the same code into a new development build and transfer it to my iPad, I found that attempts to send broadcast messages are failing. When I print out the error returned from the socket interface to the console, I see the message is "No Route to Host".
I requested multicast capability from Apple and when it appeared on my development portal I updated the App Id to include the multicast entitlement. I updated the development profile to include our new 6th gen IPad and the updated AppID. I downloaded and installed the development profile. That new profile is what I am selecting / using to sign the app.
I am using lua socket library to send broadcast messages
I created a very basic project with just the basic networking code example and built this for my iPad the results are the same.
local socket = require("socket")
local main, errorMain = socket.udp6()
main:setoption('broadcast', true)
local ack, mError = main:sendto("", "::FFFF:255.255.255.255", 3100)
print("My Debug Message: Main sending - " .. (ack or "nil") .. ", Error : " .. (mError or "None"))
I also tried modifying my code to use udp4 as follows and the results were the same.
local socket = require("socket")
local main, errorMain = socket.udp4()
main:setoption('broadcast', true)
local ack, mError = main:sendto("", "255.255.255.255", 3100)
print("My Debug Message: Main sending - " .. (ack or "nil") .. ", Error : " .. (mError or "None"))
console output: My Debug Message: Main sending - nil, Error : No route to host
Any help or insight would be greatly appreciated.
I have come up with a workaround. I am not sure how helpful the following information will be to anyone else but I will provide some details in the off-chance that someone else runs into the same issue.
So it looks like lua socket does not provide a mechanism to allow you to identify or select specific network interfaces. Instead when a lua socket send method is called lua socket attempts to send the message over all available interfaces. In this specific case that no longer seems to work with an app built using XCode15 when targeting the IP address 255.255.255.255. Each interface is rejecting the send message to that address.
By modifying some code I discovered that using a specific subnet broadcast address like (IE: 192.168.1.255) will prevent the messages from being blocked. To calculate the subnet broadcast address, a valid IP address for the subnet( can use the iOS devices IP address) and the subnet mask are required. A simple google search for "How to calculate the broadcast address" should produce a tutorial on how to do that.
Unfortunately, the tool that I use (Solar2d) does not provide a way to get the IP address and subnet mask information. So I have added a menu for users to add this information in the app.
If I had more time to solve this issue, I would learn how to create / add a BSD sockets C library, or learn how to use Corona cards to embed my app into an Xcode Swift app. That would allow me to follow some of the code examples provided on the Apple support forums to address this specific issue.