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?
Thanks!
lukasa
(Cory Benfield)
2
Yes, you can do this.
You can bind your NIOTSListenerBootstrap to a NWEndpoint. This includes a Bonjour service option, which you can use and NIOTS supports. A similar connect method exists on NIOTSConnectionBootstrap which also takes a service endpoint if you wish.
2 Likes
Thanks for the pointers!
So, in that case I wouldn't even need the NWListener? I'd just bootstrap SwiftNIO by constructing a NWEndpoint from scratch and providing my service name etc?
Edit: I had time to test this and it worked! No need for NWListener 
Thanks again @lukasa! This was a huge help.