4 <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
5 <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
9 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0">
11 <title>Managing lists of servers
— libmemcached
1.1.0 documentation
</title>
20 <script type=
"text/javascript" src=
"../_static/js/modernizr.min.js"></script>
23 <script type=
"text/javascript" id=
"documentation_options" data-url_root=
"../" src=
"../_static/documentation_options.js"></script>
24 <script type=
"text/javascript" src=
"../_static/jquery.js"></script>
25 <script type=
"text/javascript" src=
"../_static/underscore.js"></script>
26 <script type=
"text/javascript" src=
"../_static/doctools.js"></script>
27 <script type=
"text/javascript" src=
"../_static/language_data.js"></script>
29 <script type=
"text/javascript" src=
"../_static/js/theme.js"></script>
34 <link rel=
"stylesheet" href=
"../_static/css/theme.css" type=
"text/css" />
35 <link rel=
"stylesheet" href=
"../_static/pygments.css" type=
"text/css" />
36 <link rel=
"index" title=
"Index" href=
"../genindex.html" />
37 <link rel=
"search" title=
"Search" href=
"../search.html" />
38 <link rel=
"copyright" title=
"Copyright" href=
"../copyright.html" />
39 <link rel=
"next" title=
"Managing the servers used by memcached_st" href=
"memcached_servers.html" />
40 <link rel=
"prev" title=
"Servers and Server Lists" href=
"index_advanced_servers.html" />
43 <body class=
"wy-body-for-nav">
46 <div class=
"wy-grid-for-nav">
48 <nav data-toggle=
"wy-nav-shift" class=
"wy-nav-side">
49 <div class=
"wy-side-scroll">
50 <div class=
"wy-side-nav-search" >
54 <a href=
"../index.html" class=
"icon icon-home"> libmemcached
71 <form id=
"rtd-search-form" class=
"wy-form" action=
"../search.html" method=
"get">
72 <input type=
"text" name=
"q" placeholder=
"Search docs" />
73 <input type=
"hidden" name=
"check_keywords" value=
"yes" />
74 <input type=
"hidden" name=
"area" value=
"default" />
81 <div class=
"wy-menu wy-menu-vertical" data-spy=
"affix" role=
"navigation" aria-label=
"main navigation">
89 <li class=
"toctree-l1"><a class=
"reference internal" href=
"../libmemcached.html">Introduction
</a></li>
90 <li class=
"toctree-l1 current"><a class=
"reference internal" href=
"index.html">libmemcached API
</a><ul class=
"current">
91 <li class=
"toctree-l2"><a class=
"reference internal" href=
"index_basics.html">Basics
</a></li>
92 <li class=
"toctree-l2"><a class=
"reference internal" href=
"index_data.html">Working with Data
</a></li>
93 <li class=
"toctree-l2"><a class=
"reference internal" href=
"index_errors.html">Messages and Errors
</a></li>
94 <li class=
"toctree-l2 current"><a class=
"reference internal" href=
"index_advanced.html">Advanced Topics
</a><ul class=
"current">
95 <li class=
"toctree-l3"><a class=
"reference internal" href=
"index_advanced_internals.html">Internal Behavior
</a></li>
96 <li class=
"toctree-l3"><a class=
"reference internal" href=
"index_advanced_aeh.html">Authentication, Encryption
& Hashing
</a></li>
97 <li class=
"toctree-l3 current"><a class=
"reference internal" href=
"index_advanced_servers.html">Servers and Server Lists
</a><ul class=
"current">
98 <li class=
"toctree-l4 current"><a class=
"current reference internal" href=
"#">Managing lists of servers
</a></li>
99 <li class=
"toctree-l4"><a class=
"reference internal" href=
"memcached_servers.html">Managing the servers used by memcached_st
</a></li>
102 <li class=
"toctree-l3"><a class=
"reference internal" href=
"index_advanced_daemon.html">Affecting the memcached Daemon
</a></li>
103 <li class=
"toctree-l3"><a class=
"reference internal" href=
"index_advanced_stats.html">Statistics
</a></li>
106 <li class=
"toctree-l2"><a class=
"reference internal" href=
"index_deprecated.html">Deprecated Functionality
</a></li>
109 <li class=
"toctree-l1"><a class=
"reference internal" href=
"../libmemcachedutil/index.html">libmemcachedutil API
</a></li>
110 <li class=
"toctree-l1"><a class=
"reference internal" href=
"../libhashkit/index.html">libhashkit API
</a></li>
111 <li class=
"toctree-l1"><a class=
"reference internal" href=
"../bin/index.html">Client Applications
</a></li>
112 <li class=
"toctree-l1"><a class=
"reference internal" href=
"index_misc.html">Miscellaneous
</a></li>
115 <li class=
"toctree-l1"><a class=
"reference internal" href=
"../changelogs.html">Change Logs
</a></li>
116 <li class=
"toctree-l1"><a class=
"reference internal" href=
"../copyright.html">Copyright
</a></li>
125 <section data-toggle=
"wy-nav-shift" class=
"wy-nav-content-wrap">
128 <nav class=
"wy-nav-top" aria-label=
"top navigation">
130 <i data-toggle=
"wy-nav-top" class=
"fa fa-bars"></i>
131 <a href=
"../index.html">libmemcached
</a>
136 <div class=
"wy-nav-content">
138 <div class=
"rst-content">
156 <div role=
"navigation" aria-label=
"breadcrumbs navigation">
158 <ul class=
"wy-breadcrumbs">
160 <li><a href=
"../index.html">Docs
</a> »</li>
162 <li><a href=
"index.html">libmemcached API
</a> »</li>
164 <li><a href=
"index_advanced.html">Advanced Topics
</a> »</li>
166 <li><a href=
"index_advanced_servers.html">Servers and Server Lists
</a> »</li>
168 <li>Managing lists of servers
</li>
171 <li class=
"wy-breadcrumbs-aside">
175 <a href=
"https://github.com/m6w6/libmemcached/blob/v1.x/docs/source/libmemcached/memcached_server_st.rst" class=
"fa fa-github"> Edit on GitHub
</a>
186 <div role=
"main" class=
"document" itemscope=
"itemscope" itemtype=
"http://schema.org/Article">
187 <div itemprop=
"articleBody">
189 <div class=
"section" id=
"managing-lists-of-servers">
190 <h1>Managing lists of servers
<a class=
"headerlink" href=
"#managing-lists-of-servers" title=
"Permalink to this headline">¶
</a></h1>
191 <div class=
"section" id=
"synopsis">
192 <h2>SYNOPSIS
<a class=
"headerlink" href=
"#synopsis" title=
"Permalink to this headline">¶
</a></h2>
193 <dl class=
"docutils">
194 <dt>#include
<libmemcached/memcached.h
></dt>
195 <dd>Compile and link with -lmemcached
</dd>
198 <dt id=
"c.memcached_instance_st">
199 struct
<a class=
"reference internal" href=
"#c.memcached_instance_st" title=
"memcached_instance_st">memcached_instance_st
</a> <code class=
"descname">memcached_instance_st
</code><a class=
"headerlink" href=
"#c.memcached_instance_st" title=
"Permalink to this definition">¶
</a></dt>
203 <dt id=
"c.memcached_server_st">
204 struct
<a class=
"reference internal" href=
"#c.memcached_server_st" title=
"memcached_server_st">memcached_server_st
</a> <code class=
"descname">memcached_server_st
</code><a class=
"headerlink" href=
"#c.memcached_server_st" title=
"Permalink to this definition">¶
</a></dt>
208 <dt id=
"c.memcached_server_list_st">
209 struct
<a class=
"reference internal" href=
"#c.memcached_server_st" title=
"memcached_server_st">memcached_server_st
</a> *
<code class=
"descname">memcached_server_list_st
</code><a class=
"headerlink" href=
"#c.memcached_server_list_st" title=
"Permalink to this definition">¶
</a></dt>
212 <dl class=
"function">
213 <dt id=
"_CPPv426memcached_server_list_free24memcached_server_list_st">
214 <span id=
"_CPPv326memcached_server_list_free24memcached_server_list_st"></span><span id=
"_CPPv226memcached_server_list_free24memcached_server_list_st"></span><span id=
"memcached_server_list_free__memcached_server_list_st"></span>void
<code class=
"descname">memcached_server_list_free
</code><span class=
"sig-paren">(
</span>memcached_server_list_st
<em>list
</em><span class=
"sig-paren">)
</span><a class=
"headerlink" href=
"#_CPPv426memcached_server_list_free24memcached_server_list_st" title=
"Permalink to this definition">¶
</a><br /></dt>
215 <dd><table class=
"docutils field-list" frame=
"void" rules=
"none">
216 <col class=
"field-name" />
217 <col class=
"field-body" />
219 <tr class=
"field-odd field"><th class=
"field-name">Parameters:
</th><td class=
"field-body"><strong>list
</strong> -- instance of initialized
<code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_server_list_st
</span></code> object
</td>
225 <dl class=
"function">
226 <dt id=
"_CPPv428memcached_server_list_append24memcached_server_list_stPKc9in_port_tP18memcached_return_t">
227 <span id=
"_CPPv328memcached_server_list_append24memcached_server_list_stPKc9in_port_tP18memcached_return_t"></span><span id=
"_CPPv228memcached_server_list_append24memcached_server_list_stPKc9in_port_tP18memcached_return_t"></span><span id=
"memcached_server_list_append__memcached_server_list_st.cCP.in_port_t.memcached_return_tP"></span>memcached_server_list_st
<code class=
"descname">memcached_server_list_append
</code><span class=
"sig-paren">(
</span>memcached_server_list_st
<em>list
</em>,
<em class=
"property">const
</em> char *
<em>hostname
</em>, in_port_t
<em>port
</em>,
<a class=
"reference internal" href=
"memcached_return_t.html#_CPPv418memcached_return_t" title=
"memcached_return_t">memcached_return_t
</a> *
<em>error
</em><span class=
"sig-paren">)
</span><a class=
"headerlink" href=
"#_CPPv428memcached_server_list_append24memcached_server_list_stPKc9in_port_tP18memcached_return_t" title=
"Permalink to this definition">¶
</a><br /></dt>
228 <dd><table class=
"docutils field-list" frame=
"void" rules=
"none">
229 <col class=
"field-name" />
230 <col class=
"field-body" />
232 <tr class=
"field-odd field"><th class=
"field-name">Parameters:
</th><td class=
"field-body"><ul class=
"first simple">
233 <li><strong>list
</strong> -- instance of an existing
<code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_server_list_st
</span></code> or nullptr to create one
</li>
234 <li><strong>hostname
</strong> -- the hostname or path to the socket, defaults to localhost if null
</li>
235 <li><strong>port
</strong> -- the port to use, defaults to
11211 if
0</li>
236 <li><strong>error
</strong> -- pointer to store any
<a class=
"reference internal" href=
"memcached_return_t.html#_CPPv418memcached_return_t" title=
"memcached_return_t"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_return_t
</span></code></a> error indicating success
</li>
240 <tr class=
"field-even field"><th class=
"field-name">Returns:
</th><td class=
"field-body"><p class=
"first last">new instance of
<code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_server_list_st
</span></code> on success or nullptr on failure
</p>
247 <dl class=
"function">
248 <dt id=
"_CPPv427memcached_server_list_count24memcached_server_list_st">
249 <span id=
"_CPPv327memcached_server_list_count24memcached_server_list_st"></span><span id=
"_CPPv227memcached_server_list_count24memcached_server_list_st"></span><span id=
"memcached_server_list_count__memcached_server_list_st"></span>uint32_t
<code class=
"descname">memcached_server_list_count
</code><span class=
"sig-paren">(
</span>memcached_server_list_st
<em>list
</em><span class=
"sig-paren">)
</span><a class=
"headerlink" href=
"#_CPPv427memcached_server_list_count24memcached_server_list_st" title=
"Permalink to this definition">¶
</a><br /></dt>
250 <dd><table class=
"docutils field-list" frame=
"void" rules=
"none">
251 <col class=
"field-name" />
252 <col class=
"field-body" />
254 <tr class=
"field-odd field"><th class=
"field-name">Parameters:
</th><td class=
"field-body"><strong>list
</strong> -- instance of
<code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_server_list_st
</span></code></td>
256 <tr class=
"field-even field"><th class=
"field-name">Returns:
</th><td class=
"field-body">count of servers in the list
</td>
262 <dl class=
"function">
263 <dt id=
"_CPPv422memcached_server_errorPK21memcached_instance_st">
264 <span id=
"_CPPv322memcached_server_errorPK21memcached_instance_st"></span><span id=
"_CPPv222memcached_server_errorPK21memcached_instance_st"></span><span id=
"memcached_server_error__memcached_instance_stCP"></span><em class=
"property">const
</em> char *
<code class=
"descname">memcached_server_error
</code><span class=
"sig-paren">(
</span><em class=
"property">const
</em> memcached_instance_st *
<em>instance
</em><span class=
"sig-paren">)
</span><a class=
"headerlink" href=
"#_CPPv422memcached_server_errorPK21memcached_instance_st" title=
"Permalink to this definition">¶
</a><br /></dt>
265 <dd><table class=
"docutils field-list" frame=
"void" rules=
"none">
266 <col class=
"field-name" />
267 <col class=
"field-body" />
269 <tr class=
"field-odd field"><th class=
"field-name">Parameters:
</th><td class=
"field-body"><strong>instance
</strong> -- pointer to an initialized
<code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached_instance_st
</span></code> object
</td>
271 <tr class=
"field-even field"><th class=
"field-name">Returns:
</th><td class=
"field-body">last error message sent from the server to the client
</td>
277 <dl class=
"function">
278 <dt id=
"_CPPv428memcached_server_error_resetPK21memcached_instance_st">
279 <span id=
"_CPPv328memcached_server_error_resetPK21memcached_instance_st"></span><span id=
"_CPPv228memcached_server_error_resetPK21memcached_instance_st"></span><span id=
"memcached_server_error_reset__memcached_instance_stCP"></span>void
<code class=
"descname">memcached_server_error_reset
</code><span class=
"sig-paren">(
</span><em class=
"property">const
</em> memcached_instance_st *
<em>list
</em><span class=
"sig-paren">)
</span><a class=
"headerlink" href=
"#_CPPv428memcached_server_error_resetPK21memcached_instance_st" title=
"Permalink to this definition">¶
</a><br /></dt>
280 <dd><div class=
"deprecated">
281 <p><span class=
"versionmodified">Deprecated since version
0.39.
</span></p>
285 <dl class=
"function">
286 <dt id=
"_CPPv423memcached_servers_parsev">
287 <span id=
"_CPPv323memcached_servers_parsev"></span><span id=
"_CPPv223memcached_servers_parsev"></span><span id=
"memcached_servers_parse"></span>void
<code class=
"descname">memcached_servers_parse
</code><span class=
"sig-paren">(
</span><span class=
"sig-paren">)
</span><a class=
"headerlink" href=
"#_CPPv423memcached_servers_parsev" title=
"Permalink to this definition">¶
</a><br /></dt>
288 <dd><div class=
"deprecated">
289 <p><span class=
"versionmodified">Deprecated since version
0.39.
</span></p>
291 <p>See
<a class=
"reference internal" href=
"configuration.html#_CPPv49memcachedPKc6size_t" title=
"memcached"><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">memcached()
</span></code></a>.
</p>
295 <div class=
"section" id=
"description">
296 <h2>DESCRIPTION
<a class=
"headerlink" href=
"#description" title=
"Permalink to this headline">¶
</a></h2>
297 <p><code class=
"xref cpp cpp-any docutils literal notranslate"><span class=
"pre">libmemcached
</span></code> operates on a list of hosts which are stored in
298 <code class=
"xref cpp cpp-type docutils literal notranslate"><span class=
"pre">memcached_server_st
</span></code> structures. You should not modify these structures
299 directly. Functions are provided to modify these structures.
</p>
300 <p><code class=
"xref cpp cpp-func docutils literal notranslate"><span class=
"pre">memcached_server_list()
</span></code> is used to provide an array of all defined hosts.
301 This was incorrectly documented as
"requiring free
" up till version
0.39.
</p>
302 <p><a class=
"reference internal" href=
"#_CPPv426memcached_server_list_free24memcached_server_list_st" title=
"memcached_server_list_free"><code class=
"xref cpp cpp-func docutils literal notranslate"><span class=
"pre">memcached_server_list_free()
</span></code></a> deallocates all memory associated with the
303 array of
<code class=
"xref cpp cpp-type docutils literal notranslate"><span class=
"pre">memcached_server_st
</span></code> that you passed to it.
</p>
304 <p><a class=
"reference internal" href=
"#_CPPv428memcached_server_list_append24memcached_server_list_stPKc9in_port_tP18memcached_return_t" title=
"memcached_server_list_append"><code class=
"xref cpp cpp-func docutils literal notranslate"><span class=
"pre">memcached_server_list_append()
</span></code></a> adds a server to the end of a
305 <code class=
"xref cpp cpp-type docutils literal notranslate"><span class=
"pre">memcached_server_st
</span></code> array. On error null will be returned and the
306 <a class=
"reference internal" href=
"memcached_return_t.html#_CPPv418memcached_return_t" title=
"memcached_return_t"><code class=
"xref cpp cpp-type docutils literal notranslate"><span class=
"pre">memcached_return_t
</span></code></a> pointer you passed into the function will be set with the appropriate error. If the value of port is zero, it is set to the default
307 port of a memcached server.
</p>
308 <p>DEPRECATED
<a class=
"reference internal" href=
"#_CPPv423memcached_servers_parsev" title=
"memcached_servers_parse"><code class=
"xref cpp cpp-func docutils literal notranslate"><span class=
"pre">memcached_servers_parse()
</span></code></a>, please see
<a class=
"reference internal" href=
"configuration.html#_CPPv49memcachedPKc6size_t" title=
"memcached"><code class=
"xref cpp cpp-func docutils literal notranslate"><span class=
"pre">memcached()
</span></code></a></p>
309 <p><a class=
"reference internal" href=
"#_CPPv422memcached_server_errorPK21memcached_instance_st" title=
"memcached_server_error"><code class=
"xref cpp cpp-func docutils literal notranslate"><span class=
"pre">memcached_server_error()
</span></code></a> can be used to look at the text of the last
310 error message sent by the server to to the client.
</p>
311 <p>Before version
0.39 theses functions used a memcached_server_st *. In
0.39
312 memcached_server_st * was aliased to
<code class=
"xref cpp cpp-type docutils literal notranslate"><span class=
"pre">memcached_server_list_st
</span></code>.
313 This was done for a style reason to help clean up some concepts in the code.
</p>
315 <div class=
"section" id=
"return-value">
316 <h2>RETURN VALUE
<a class=
"headerlink" href=
"#return-value" title=
"Permalink to this headline">¶
</a></h2>
317 <p>Varies, see particular functions.
</p>
319 <div class=
"section" id=
"see-also">
320 <h2>SEE ALSO
<a class=
"headerlink" href=
"#see-also" title=
"Permalink to this headline">¶
</a></h2>
322 <li><em class=
"manpage"><a class=
"manpage reference external" href=
"https://linux.die.net/man/1/memcached">memcached(
1)
</a></em></li>
323 <li><a class=
"reference internal" href=
"../libmemcached.html"><span class=
"doc">C/C++ Client Library for memcached
</span></a></li>
324 <li><a class=
"reference internal" href=
"memcached_servers.html"><span class=
"doc">Managing the servers used by memcached_st
</span></a></li>
325 <li><a class=
"reference internal" href=
"memcached_strerror.html"><span class=
"doc">Converting Error Codes to Messages
</span></a></li>
336 <div class=
"rst-footer-buttons" role=
"navigation" aria-label=
"footer navigation">
338 <a href=
"memcached_servers.html" class=
"btn btn-neutral float-right" title=
"Managing the servers used by memcached_st" accesskey=
"n" rel=
"next">Next
<span class=
"fa fa-arrow-circle-right"></span></a>
341 <a href=
"index_advanced_servers.html" class=
"btn btn-neutral float-left" title=
"Servers and Server Lists" accesskey=
"p" rel=
"prev"><span class=
"fa fa-arrow-circle-left"></span> Previous
</a>
348 <div role=
"contentinfo">
350 © <a href=
"../copyright.html">Copyright
</a>
354 Built with
<a href=
"http://sphinx-doc.org/">Sphinx
</a> using a
<a href=
"https://github.com/rtfd/sphinx_rtd_theme">theme
</a> provided by
<a href=
"https://readthedocs.org">Read the Docs
</a>.
367 <script type=
"text/javascript">
369 SphinxRtdTheme.Navigation.enable(true);