+ rc= set_hostinfo(&ptr->hosts[server_key]);
+ if (rc != MEMCACHED_SUCCESS)
+ return rc;
+ ptr->hosts[server_key].sockaddr_inited= MEMCACHED_ALLOCATED;
+ }
+ use= ptr->hosts[server_key].address_info;
+
+ /* Create the socket */
+ if ((ptr->hosts[server_key].fd= socket(use->ai_family,
+ use->ai_socktype,
+ use->ai_protocol)) < 0)
+ {
+ ptr->cached_errno= errno;
+ WATCHPOINT_ERRNO(errno);
+ return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE;
+ }
+
+ /* For the moment, not getting a nonblocking mode will not be fatal */
+ if (ptr->flags & MEM_NO_BLOCK)
+ {
+ int flags;
+
+ flags= fcntl(ptr->hosts[server_key].fd, F_GETFL, 0);
+ if (flags != -1)
+ (void)fcntl(ptr->hosts[server_key].fd, F_SETFL, flags | O_NONBLOCK);
+ }
+
+ if (ptr->flags & MEM_TCP_NODELAY)
+ {
+ int flag= 1;
+
+ setsockopt(ptr->hosts[server_key].fd, IPPROTO_TCP, TCP_NODELAY,
+ &flag, (socklen_t)sizeof(int));
+ }
+
+ if (ptr->send_size)
+ {
+ setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_SNDBUF,
+ &ptr->send_size, (socklen_t)sizeof(int));
+ }
+
+ if (ptr->recv_size)
+ {
+ setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_SNDBUF,
+ &ptr->recv_size, (socklen_t)sizeof(int));
+ }
+
+ /* connect to server */