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 |