<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.zookeeper.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'zookeeper.connect.php',
    1 => 'Zookeeper::connect',
    2 => 'Create a handle to used communicate with zookeeper',
  ),
  'up' => 
  array (
    0 => 'class.zookeeper.php',
    1 => 'Zookeeper',
  ),
  'prev' => 
  array (
    0 => 'zookeeper.close.php',
    1 => 'Zookeeper::close',
  ),
  'next' => 
  array (
    0 => 'zookeeper.construct.php',
    1 => 'Zookeeper::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/zookeeper/zookeeper/connect.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="zookeeper.connect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Zookeeper::connect</h1>
  <p class="verinfo">(PECL zookeeper &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">Zookeeper::connect</span> &mdash; <span class="dc-title">Create a handle to used communicate with zookeeper</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-zookeeper.connect-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>Zookeeper::connect</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$host</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$watcher_cb</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$recv_timeout</code><span class="initializer"> = 10000</span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>


  <p class="para rdfs-comment">
   This method creates a new handle and a zookeeper session that corresponds to that handle. Session establishment is asynchronous, meaning that the session should not be considered established until (and unless) an event of state ZOO_CONNECTED_STATE is received.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-zookeeper.connect-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">host</code></dt>
    <dd>
     <p class="para">
      Comma separated host:port pairs, each corresponding to a zk server. e.g. &quot;127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002&quot;
     </p>
    </dd>
   
   
    <dt><code class="parameter">watcher_cb</code></dt>
    <dd>
     <p class="para">
      The global watcher callback function. When notifications are triggered this function will be invoked.
     </p>
    </dd>
   
   
    <dt><code class="parameter">recv_timeout</code></dt>
    <dd>
     <p class="para">
      The timeout for this session, only valid if the connections is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE).
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-zookeeper.connect-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-zookeeper.connect-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   This method emits PHP error/warning when parameters count or types are wrong or could not init instance.
  </p>
  <div class="caution"><strong class="caution">警告</strong>
    <p class="para">
      Since version 0.3.0, this method emits <span class="classname"><a href="class.zookeeperexception.php" class="classname">ZookeeperException</a></span> and it&#039;s derivatives.
    </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-zookeeper.connect-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="zookeeper.construct.php" class="methodname" rel="rdfs-seeAlso">Zookeeper::__construct()</a> - Create a handle to used communicate with zookeeper</span></li>
   <li><span class="classname"><a href="class.zookeeperexception.php" class="classname">ZookeeperException</a></span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>