moved freeaddrinfo(results); if(rp == NULL) would be incorrectly true.