Fixed IPv6 support.

getaddrinfo() is way better than gethostbyname().
Fixed a syntax error under debug mode.
Fixed detection of libpng.