port to FreeBSD 10 & OSX 10.9.5

I have verified that this works on FreeBSD 10.  I left it running overnight with no issues.

On OS X I can build it, but it is failing with errno 65 'no route to host'? even though it actually works.
I can route around the issue by setting errno=0 just before the reconnect checks in the two clients.
I've done some instrumentation to try to discover which syscall is setting errno, but I've run out of time to work on this today.

Please look at these lines again.  You are decoding a little-endian byte stream into a host integer, then applying an unnecessary byte swap to it.  This will do nothing on little-endian, but will scramble the integer on a big-endian platform.

This is why I think these endian functions are a Bad Idea.  They violate the very idea of a typed integer, and encourage bad habits (like casting packet data to a structure).