tcp: use getaddrinfo() for hostname resolution

gethostbyname_r() is GNU extension not supported on some platforms.
This commit replaces it with POSIX standard getaddrinfo() call.