rework IPv4 to use POSIX API for detecting valid IPv4 address
add IPv6 detection that uses POSIX API as well