Refactored network to use getaddrinfo