I have an iPad app that uses Network framework to allow iPads to wirelessly communicate via their built-in ad hoc network capability. However, our app is used in an enterprise environment and there's concern about them communicating wirelessly, so I've been tasked with looking into wired communication.
Question:
I've read that iOS can connect to a wifi network using an Ethernet adapter, but would this work for ad hoc networking? For ex, if I connect 2 iPads via Ethernet cables to each other (not to the wifi router), and have the NWListener start broadcasting itself, can the NWBrowser find it and establish an ad-hoc connection via the Ethernet cables (and not the wireless cards inside the iPads). The iPads don't have any wifi connections established so they wouldn't be able to communicate any other way.
My guess is no...though if they did connect, how would I know it has happening via the cables and not via the wireless ad hoc capability, because I'm guessing there's no way to turn off just the wireless part of the ad hoc feature? If you disable the wifi on an iPad, you're also disabling ad hoc, right?
I'm pretty sure there's no way to programmatically send data back and forth between iPads using a USB-C cable connection, so I'm trying to determine if Ethernet cables would work.
I don’t use the term ad hoc when it comes to networking because it means different things to do different people. I talk about that more in Wi-Fi Fundamentals.
iOS can connect to a wifi network using an Ethernet adapter
You obviously can’t connect to a Wi-Fi network with an Ethernet adapter. I’m going to presume you meant “Ethernet network”.
but would this work [without infrastructure]?
Yes.
how would I know it has happening via the cables and not via [peer-to-peer Wi-Fi] … ?
For testing, just turn off Wi-Fi.
IMPORTANT It’s critical you do this from Settings > Wi-Fi. Turning off Wi-Fi from Control Centre doesn’t actually turn it off, allowing peer-to-peer Wi-Fi to kick in.
Programmatically, you can:
-
Force Network framework to use Ethernet via the
requiredInterfaceType
property. -
Or allow the connection to go through and then inspect the
currentPath
property.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"