+
+
+memcached_return memcached_connect(memcached_st *ptr, unsigned int server_key)
+{
+ memcached_return rc;
+ LIBMEMCACHED_MEMCACHED_CONNECT_START();
+
+ if (ptr->connected == ptr->number_of_hosts)
+ return MEMCACHED_SUCCESS;
+
+ if (!ptr->hosts)
+ return MEMCACHED_NO_SERVERS;
+
+ /* We need to clean up the multi startup piece */
+ if (server_key)
+ rc= memcached_real_connect(ptr, server_key);
+ else
+ {
+ unsigned int x;
+
+ for (x= 0; x < ptr->number_of_hosts; x++)
+ rc= memcached_real_connect(ptr, x);
+ }
+ LIBMEMCACHED_MEMCACHED_CONNECT_END();
+
+ return rc;
+}