• 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: NSNetServiceBrowser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNetServiceBrowser


  • Subject: Re: NSNetServiceBrowser
  • From: Chris Parker <email@hidden>
  • Date: Tue, 6 May 2003 22:04:24 -0700

Hi Lloyd,

On Tuesday, May 6, 2003, at 9:33 PM, Lloyd Dupont wrote:

I have a simple service which runs on all ours computers as a startup
items. I communicate to them through DO (using NSSocketPort) now, I
try to advertise them with Rendezvous to have a (magic) "zero
configuration" access to each of them.

My concern is while I am able to get NSNetServiceBrowser to get them
(the delegate method
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser
didFindService:(NSNetService *)aNetService
moreComing:(BOOL)moreComing
return me all services
)
I'm unable to get the port and host information from the NSNetService
(which is crucial to properly initialize NSSocketPort), although I
correctly initialize my NSNetService with this initializer:
NSNetService * myService = [[NSNetService alloc] initWithDomain:@""

type:@"_myProtocol._tcp."

name:@"my service"

port:MY_PORT];


I can't get its host and port.
any idea ? tips ? links ?

When you get the NSNetService back from the browser, you're being told that something out on your local subnet is advertising a particular service. Let's call that 'foo'.

You'll want to call [foo resolve] and when that tells you that it resolved (via another delegate), call [foo addresses] to retrieve an array of addresses for that service.

Each address is an NSData containing an struct sockaddr_in suitable for socket creation.

The updated Picture Sharing Browser example at

http://developer.apple.com/samplecode/Sample_Code/Networking/ PictureSharingBrowser.htm

shows how to do this as well as making sure that the resolves are stopped to minimize network traffic, etc.

.chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSNetServiceBrowser
      • From: Lloyd Dupont <email@hidden>
    • Re: NSNetServiceBrowser
      • From: Lloyd Dupont <email@hidden>
References: 
 >NSNetServiceBrowser (From: Lloyd Dupont <email@hidden>)

  • Prev by Date: Re: How do I create and use a framework...
  • Next by Date: Re: NSNetServiceBrowser
  • Previous by thread: NSNetServiceBrowser
  • Next by thread: Re: NSNetServiceBrowser
  • Index(es):
    • Date
    • Thread