fix build on freebsd
fix NetBSD, which has fixed-length struct ifreq objects
fix Solaris build
fix misuse of SOCK_CLOEXEC which Linux silently ignored but NetBSD thankfully complained about