Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OS X / Xcode: Getting TXT record using NSNetServiceBrowser




On Nov 18, 2004, at 6:16 PM, Andrew White wrote:

Under OS X 10.3 / Xcode 1.5:

I can use NSNetServiceBrowser to resolve services, obtaining addresses,
domain, name and type. However, I can't see any way to obtain the port or
the TXT record. I know a port and TXT record are being advertised (I can
see them using command line applications).


I tried using the 'protocolSpecificInformation' method, which returns an
NSString *, but this string came back empty.


Does the high level NSNetService API support this, or do I need to call the
DNS-SD API directly?

An individual NSNetService instance may be publishing itself on multiple ports or addresses. Once an NSNetService instance is resolved you can get the array of addresses from the instance using the -addresses method. Each entry is an NSData containing a struct sockaddr_in (or the IPv6 version thereof) which you can pick at for the port for that particular service.


You can see this in the example code at /Developer/Examples/Foundation/Picture Sharing Browser in the -netServiceDidResolveAddress: method (look for "if (socketAddress)" in the code).

-protocolSpecificInformation was unfortunately pretty much deprecated at publication, so you may have to use the raw DNS-SD APIs if that's vital to you for arbitrary items, but for information published in a like manner (i.e. the other side called -setProtocolSpecificInformation on the NSNetService instance it's publishing) it should work.

.chris

--
Chris Parker
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Rendezvous-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/rendezvous-dev/email@hidden

This email sent to email@hidden
References: 
 >OS X / Xcode: Getting TXT record using NSNetServiceBrowser (From: Andrew White <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.