Hello,
I am studying the Building peer-to-peer apps codebase https://developer.apple.com/documentation/wifiaware/building-peer-to-peer-apps and am wondering why no connection is ever started?
I searched the codebase and didn't find .start() be called once.
Start function I'm referencing https://developer.apple.com/documentation/network/networkconnection/start()
Are NetworkConnections started automatically?
Note that I am using QUIC NetworkConnections (NetworkConnection<QUIC>) in what I'm trying to do.
In the new API — so, NetworkConnection not NWConnection — there’s no explicit ‘start’ method. Rather, the connection starts implicitly when you do something that needs it.
The exception to this rule is QUIC. In that case you can start the QUIC tunnel using that start() method you referenced. That’s useful when you want to start the tunnel but don’t want to immediately start any connections over that tunnel.
However, this is optional. Starting a stream over the tunnel will implicitly start the tunnel.
Note this comment in that page:
Available when
ApplicationProtocolconforms toMultiplexProtocol.
QUIC is the only MultiplexProtocol currently available, so it’s the only place this method is available. So, it’s not available for TCP, or even for QUIC streams within a tunnel.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"