Bz/fix freebsd

Fix issues. Tested with freeBSD 9.2 and 10.
Is the issue that `AI_V4MAPPED` is defined but it doesn't behave as expected?