Hi all, I’m writing an app that begins a NetService on tvOS and connects to it from iOS. I’m creating the service with a port number of 0 to get an automatic port and publishing with the .listenForConnections option. On the client (iOS) side, once I resolve an address for the service I use its getInputStream(_:outputStream:) method to get input and output streams set up. I create a background thread to handle callbacks on and schedule the streams on its RunLoop.
What I’m noticing is that I get a lot of stream errors with this setup. I’m using JSONSerialization to write JSON objects to the stream and for the most part it works, but when I get these errors I’d like to reconnect. It seems like I can’t just call getInputStream(_:outputStream:) again on the resolved service, as doing so gives me all kinds of errors about a socket not being available. My next thing to try will be to rediscover the service, using its TXT data to make sure it’s the same one, re-resolve the address, and try again. I’m pretty new to Bonjour and there aren’t a whole lot of resources out there for how to handle stream errors. Am I on the right track? What kind of gotchas should I be aware of here (for instance, is there a hard number of clients that could conceivably connect to a NetService on an Apple TV)? Thanks in advance for any pointers! Jeff Kelley [email protected] | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org (Cross-posted from cocoa-dev, sorry for the noise to those who get this twice!)
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com This email sent to [email protected]
