On Nov 30, 2009, at 9:27 AM, Joe Turner wrote:
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.
Might be a problem with your data framing (knowing where a message begins/ends). If NSKeyedArchiver is crashing, you definitely don't want to use that in network code, then, or it's a security vulnerability (DoS attack).
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.
Again, apples and oranges. Bonjour tells you whether the other machine is reachable on the subnet and is advertising a specific service. That's independent of whether you have a functioning TCP socket to the other side; Bonjour doesn't know or care about that.
What errors do you get when you try and fail to send data? Are you sure the socket is still alive — do you listen for notifications that it closed?
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.
This can happen occasionally, especially if a machine gets abruptly disconnected from the network (Ethernet yanked, power fails, kernel panic, etc.) Bonjour records have timeouts, to avoid flooding the network with status-update traffic, so if a machine doesn't have a chance to broadcast that its services are going away, they can hang around for a few minutes.
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.
I'm not sure exactly how Bonjour interacts with the [pointless] built-in firewall configuration. It may be that it won't advertise a service if the firewall prevents listening on that port.
And then, a reason to move away from bonjour is: So one can connect to people not on the same network.
Taking out Bonjour support isn't going to make that any easier. All it will do is introduce the new problem if how to connect to people who are on the same network. This is a difficult problem. If you don't want to make people yell their IP addresses across the room, and type them in without errors, you basically have to end up re-implementing what Bonjour does (link-local multicasting of advertisements) only without having had most of a decade to debug and fine-tune the implementation. You're also going to have to learn a lot about UDP networking and the care and feeding of multicast sockets. :-P
—Jens