Thanks for the response,
Originally, I was having issues with unarchiving the data sent through the NSStreams. I would use an NSKeyedArchiver and NSKeyedUnarchiver to package and unpackage it, and about half the time, the program would crash, because the NSKeyedUnarchiver would get bad data. I may have fixed this by using a property list serializer instead though.
Another issue I've had is timeouts. If there's inactivity for a while, the two services seem to disconnect. But, sometimes they are still seen as active by bonjour, the data just never makes it over.
A third issue I've had is seeing multiple occurrences of the same bonjour service. And when this happened, one of them was able to be resolved, and the other wasn't.
And then an issue in general is firewalls. Firewalls seem to completely block auto-discovery sometimes. Of course, even without using auto-discovery, a firewall can still block the connection.
And then, a reason to move away from bonjour is: So one can connect to people not on the same network.
And, I haven't really looked into it, but I assume if I don't use Bonjour, it would be much easier to port a Windows client as well.
Thanks,
Joe On Nov 30, 2009, at 10:53 AM, Jens Alfke wrote: On Nov 29, 2009, at 6:39 PM, Joe Turner wrote: I've been using NSNetservices over bonjour for a while for network programming, and they always seem to give me trouble. I'm thinking of completely switching away from auto-discovery, and would like to get into low-level unix networking.
I think you're mixing apples and oranges here. NSNetService (and related Bonjour APIs) are for service discovery: they identify services and tell you their IP addresses. Connection and communication are up to you — you can use NSStream, CFSocket, POSIX socket calls, libcurl, OpenSSL, whatever's appropriate.
It's true that NSNetService has a method to open NSStreams, but it's just a convenience — all it does is use public APIs to resolve the service's address and then calls the NSStream factory method to open connections to that address. You certainly don't have to use it.
If you're having trouble with NSStreams for TCP sockets, that's not directly related to Bonjour or auto-discovery. Maybe if you describe the problems we can resolve them — lots of people have gotten these APIs to work reliably. You could certainly avoid those specific problems by using POSIX APIs, but you'll end up trading them for other problems :) such as threading, buffering, timeouts, multiplexing multiple sockets via select() or kqueues, ...
—Jens
|