+ struct sockaddr_in localAddr, servAddr;
+ struct hostent *h;
+
+ if (ptr->hosts[server_key].fd == -1)
+ {
+ if ((h= gethostbyname(ptr->hosts[server_key].hostname)) == NULL)
+ return MEMCACHED_HOST_LOCKUP_FAILURE;
+
+ servAddr.sin_family= h->h_addrtype;
+ memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
+ servAddr.sin_port = htons(ptr->hosts[server_key].port);
+
+ /* Create the socket */
+ if ((ptr->hosts[server_key].fd= socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ {
+ ptr->my_errno= errno;
+ return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE;
+ }