Improve compilation on Windows

MSVC doesn't provide unistd.h and sys/time.h. Another header, fcntl.h,
althought provided is not used during compilation.

MSVC doesn't provide w32api.h header (and WindowsXP macro), but it is
safe to assume that 0x0501 will represent Windows XP for the time being.
Also, MSVC and MinGW define both WINVER and (newer) _WIN32_WINNT macros
(and also NTDDI_VERSION, but that's whole other story), so both should
be overridden to support Windows XP.

MSVC and MinGW define their own EAFNOSUPPORT macro, which leads to
redefinition warning.

MSVC and MinGW provide declaration (and Windows provides implementation)
of inet_ntop function starting with Windows Vista.

MSVC doesn't provide snprintf function, but has _snprintf instead with
same signature and purpose.

MSVC doesn't provide gettimeofday function.

Tested on Windows 7 with MSVC 2013 and MinGW 4.9.2, defining _WIN32_WINNT
and WINVER to 0x0501 and 0x0600.