views:

56

answers:

1

I'd like to use CocoaHTTPServer to set up peer-to-peer communication between different instances of an application on a network. Setting up the server was quite easy, but writing the client is another story.

I have the server broadcasting over Bonjour. My client is able to find and resolve the service, but I'm stuck when it comes to getting the actual IP address and port that I can use with NSURL.

If I call [NSNetService addresses] I get the addresses in the form of an array of NSData objects, which is fine for low level networking purposes. But my plan was to use stringWithContentsOfURL: on the client side to make requests, so I need the addresses as a string or something.

Is this a sensible approach? If so, how can I get the addresses of the resolved NSNetService in a format that works with NSURL?

Thanks!

+1  A: 

Construct one from -hostName and -port perhaps?

Mike Abdullah