I'm trying to do something similar to the poster of this topic.
However I'm only interested in a connection between a macOS server and an iOS client, so using Network.framework
is a possibility for me.
Currently I am using a NWListener
to register my service for the iOS client to discover using NWBroswer
.
This works, and I get a NWConnection
with the listener.newConnectionHandler
.
listener.newConnectionHandler = { connection in
connection.cancel()
}
But, it circumvents my SwiftNIO server in the process.
The only workarounds I've seen elsewhere require using TXT records in the Bonjour service just to tell the client the actual IP:port of the SwiftNIO service (example using a Vapor server). This seems less than ideal.
Is it possible to use NIO Transport Services to bridge this gap?
- I notice that there is a
NIOTSConnectionBootstrap#withExistingNWConnection(_:)
function available. Are there any examples of how to use this? - Is there some other way to manually re-use the connection from
NWConnection
and bind it to a connection in SwiftNIO?
Thanks!