Further improve OFTCPSocket.

Only use getaddrinfo() if it's thread-safe - it does not make much
sense to allow getaddrinfo() if it's not thread-safe, as then its
biggest advantage to gethostbyname() is gone.

Also, copy the result from gethostbyname() so we can release the lock
before connecting - this should greatly improve the speed when trying
to connect to multiple hosts without a thread-safe getaddrinfo().