Update headers.
[m6w6/libmemcached] / libmemcached / util / ping.c
1 /* LibMemcached
2 * Copyright (C) 2010 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: connects to a host, and makes sure it is alive.
9 *
10 */
11
12 #include "libmemcached/common.h"
13 #include "libmemcached/memcached_util.h"
14
15
16 bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_return_t *ret)
17 {
18 memcached_return_t rc;
19 memcached_st memc, *memc_ptr;
20
21 memc_ptr= memcached_create(&memc);
22
23 rc= memcached_server_add(memc_ptr, hostname, port);
24
25 if (rc == MEMCACHED_SUCCESS)
26 {
27 rc= memcached_version(memc_ptr);
28 }
29
30 memcached_free(memc_ptr);
31
32 if (ret)
33 {
34 *ret= rc;
35 }
36
37 return rc == MEMCACHED_SUCCESS;
38 }