As noted here, https://developer.apple.com/forums/thread/116799 the Network framework probably won't have a connection available when running in the background.
We've been using the BGTask for a couple years now to start a URLSession and pull data from a web server. It works very nicely and reliably.
Do we have any options if we want to connect to another iPad, though? I ran a test and even if I have a "server" iPad running a Network framework listener (NWListener), and the app is in the foreground and the screen on, a "client" iPad (NWBrowser) cannot connect to the NWListener when trying to connect from the BGTask; it gives a DefunctConnection error.
Why does the Network framework not have the network available to it, but a URLSession does?
Is this a limitation of the iPad, or the Network framework? If I had an iPad running as a web server like this project,
https://github.com/swisspol/GCDWebServer
and an iPad client tries to connect a URLSession to it, would that work?
If this is an iPad limitation, could I use a MacBook on the network as a web server and connect to that instead?