<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="zmqcontext.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>ZMQContext::__construct</refname>
  <refpurpose>Construct a new ZMQContext object</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <methodname>ZMQContext::__construct</methodname>
   <methodparam choice="opt"><type>int</type><parameter>io_threads</parameter><initializer>1</initializer></methodparam>
   <methodparam choice="opt"><type>bool</type><parameter>is_persistent</parameter><initializer>&true;</initializer></methodparam>
  </methodsynopsis>
  <para>
   Constructs a new ZMQ context. The context is used to initialize sockets. A persistent context is required 
   to initialize persistent sockets. 
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>io_threads</parameter></term>
     <listitem>
      <para>
       Number of io-threads in the context.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>is_persistent</parameter></term>
     <listitem>
      <para>
       Whether the context is persistent. Persistent context is stored
       over multiple requests and is a requirement for persistent sockets.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   Throws <classname>ZMQContextException</classname> if context initialization fails.
  </para>
 </refsect1>

 <refsect1 role="examples">
 &reftitle.examples;
  <para>
   <example>
    <title>A <function>ZMQContext</function> example</title>
    <para>
     Construct a new context and allocate request socket from it
    </para>
    <programlisting role="php">
<![CDATA[
<?php
/* Allocate a new context */
$context = new ZMQContext();

/* Create a new socket */
$socket = $context->getSocket(ZMQ::SOCKET_REQ, 'my sock');

/* Connect the socket */
$socket->connect("tcp://example.com:1234");

/* Send a request */
$socket->send("Hello there");

/* Receive back the response */
$message = $socket->recv();
?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
