Fix build under FreeBSD

Hi!

This patch fixes build under FreeBSD (and maybe other systems), where EAI_NODATA and EAI_ADDRFAMILY is not defined (this seems to be non-standard).  This patch is similar to what FreeBSD has in the ports system.