• 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
Re: TCP sockets with Bonjour-discovered address
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TCP sockets with Bonjour-discovered address


  • Subject: Re: TCP sockets with Bonjour-discovered address
  • From: Josh Graessley <email@hidden>
  • Date: Tue, 01 Jul 2014 17:42:12 -0700


On Jul 1, 2014, at 5:06 PM, Jens Alfke <email@hidden> wrote:


On Jul 1, 2014, at 3:51 PM, Josh Graessley <email@hidden> wrote:

It’s better to use a connect-by-name API if you have a .local name and let the system take care of resolving that to an address and connecting.

Are you saying that service names (like jens._myservice._tcp.local) can be used as hostnames? I didn’t think that was the case; it’s never worked for me before. And I’m not sure how one gets the registered .local hostname from an NSNetService.

Or by “a connect-by-name API” do you mean -[NSNetService getInputStream:outputStream:]?

The NSNetService is a connect-by-service API and it is the best option if you have the Bonjour service.

If you have already resolved the Bonjour service to a hostname and port, you can use that hostname with an API like:

+[NSStream getStreamsToHostWithName:(NSString *)host
                               port:(NSInteger) port
                        inputStream:(NSInputStream **) sin
                       outputStream:(NSOutputStream *) sout];

Or on older iOS and OS X systems you have to resort to CFSocketStreams CFStreamCreatePairWithSocketToHost. See:
https://developer.apple.com/library/ios/qa/qa1652/_index.html

The worst option is to resolve the Bonjour service all the way to address(es) and a port and then connect to one of those addresses. The more information you give the system the more flexibility the system has in how it tries to connect to that service.

Best: connect-by-service
Better: connect-by-hostname & port
Works most of the time: connect-by-address & port

-josh

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: TCP sockets with Bonjour-discovered address
      • From: Carl Hoefs <email@hidden>
References: 
 >TCP sockets with Bonjour-discovered address (From: Carl Hoefs <email@hidden>)
 >Re: TCP sockets with Bonjour-discovered address (From: Jens Alfke <email@hidden>)
 >Re: TCP sockets with Bonjour-discovered address (From: Josh Graessley <email@hidden>)
 >Re: TCP sockets with Bonjour-discovered address (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: TCP sockets with Bonjour-discovered address
  • Next by Date: Question on NSOutputStream -write:maxLength:
  • Previous by thread: Re: TCP sockets with Bonjour-discovered address
  • Next by thread: Re: TCP sockets with Bonjour-discovered address
  • Index(es):
    • Date
    • Thread