I've started working on an implementation of (NS)NetService (https://github.com/Bouke/NetService), in pure Swift. My goal is to stay close to the version in Cocoa. While I've got an intial working version, I've hit a snag. When publishing a NetService, you can also listen for connections for that service:
let ns = NetService(domain: "local.", type: "_airplay._tcp.", name: "demo", port: 7000)
The NetService's delegate has a method for accepting connections:
func netService(_ sender: NetService,
didAcceptConnectionWith inputStream: InputStream,
I've setup a CFSocket for listening and inside the accept callback it creates a CFReadStream and a CFWriteStream using CFStreamCreatePairWithSocket. The problem is that CFNetwork is not available on Linux and probably will never be. So CFStreamCreatePairWithSocket is not available.
So the question is; how to create InputStream and OutputStream inside the accept callback without CFNetwork?