working on code cleaning
removed gethostbyname (deprecated). Using getaddrinfo instead