close depends on unistd.h - explicitly include it
Free result of getaddrinfo in both success and failure cases