- struct hostent *h;
-#ifdef HAVE_GETHOSTBYNAME_R
- struct hostent h_static;
- char buffer[SMALL_STRING_LEN];
- int tmp_error;
-
- if (gethostbyname_r(server->hostname,
- &h_static, buffer, SMALL_STRING_LEN,
- &h, &tmp_error))
- {
- WATCHPOINT_STRING(server->hostname);
- WATCHPOINT_STRING(hstrerror(tmp_error));
- return MEMCACHED_HOST_LOOKUP_FAILURE;
- }
-#else
- if ((h= gethostbyname(server->hostname)) == NULL)
+ struct addrinfo *ai;
+ struct addrinfo hints;
+ int e;
+ char str_port[NI_MAXSERV];
+
+ sprintf(str_port, "%u", server->port);
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family= AF_INET;
+ hints.ai_socktype= SOCK_STREAM;
+ hints.ai_protocol= 0;
+
+ e= getaddrinfo(server->hostname, str_port, &hints, &ai);
+ if (e != 0)