• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reconnecting to a NetService after a stream error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reconnecting to a NetService after a stream error


  • Subject: Reconnecting to a NetService after a stream error
  • From: Jeff Kelley <email@hidden>
  • Date: Wed, 3 May 2017 11:38:18 -0400

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@hidden | @SlaunchaMan <https://twitter.com/SlaunchaMan> |
jeffkelley.org
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: strange behaviour of hasPrefix
  • Next by Date: NSSplitView Problems
  • Previous by thread: Re: strange behaviour of hasPrefix
  • Next by thread: NSSplitView Problems
  • Index(es):
    • Date
    • Thread