views:

130

answers:

1

I'm trying to programmatically discover and then mount network volumes shared using OS X's file sharing from a Cocoa app. I'm using NSNetServiceBrowser to discover which servers are advertising file sharing - easy enough.

My question is about the next step - how do you discover what shares are available for a given machine? ie. given that AFP URLs look something like this:

afp://SomeMac._afpovertcp._tcp.local/SomeVolume
afp://SomeMac._afpovertcp._tcp.local/OtherVolume

how do I discover the share names that make up that last url component? Surely I don't have to make low-level AFP calls for this!

+2  A: 

If by "low-level AFP calls" you mean FPGetSrvrParms(), then almost certainly that's exactly what you would need to do. Bonjour (NSNetServiceBrowser) is intended to discover services, not perform service-specific communications. AFP is the service. Each volume is not its own service any more than you would expect to access individual HTTP URLs through NSNetServiceBrowser.

I don't believe there's a Cocoa interface to AFP. Bill Monk wrote up some simple code for mounting that you might find useful.

Rob Napier
Yes I was hoping not to have to open a TCP socket and speak AFP over it in order to discover the share names before the mounting stage. Looks like I might have to though.
Adrian