Clean up getaddrinfo a bit and fix port parsing