<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.14">
  <compounddef id="ZMQComm_8h" kind="file" language="C++">
    <compoundname>ZMQComm.h</compoundname>
    <includes refid="CommBase_8h" local="no">CommBase.h</includes>
    <includes refid="comm__header_8h" local="yes">comm_header.h</includes>
    <includedby refid="communication_8h" local="no">/root/cis_interface/cis_interface/cis_interface/communication/communication.h</includedby>
    <includedby refid="DefaultComm_8h" local="no">/root/cis_interface/cis_interface/cis_interface/communication/DefaultComm.h</includedby>
    <incdepgraph>
      <node id="276">
        <label>stdint.h</label>
        <link refid="stdint_8h_source"/>
        <childnode refid="277" relation="include">
        </childnode>
        <childnode refid="278" relation="include">
        </childnode>
      </node>
      <node id="271">
        <label>stdarg.h</label>
      </node>
      <node id="281">
        <label>../dataio/AsciiTable.h</label>
        <link refid="AsciiTable_8h_source"/>
        <childnode refid="267" relation="include">
        </childnode>
        <childnode refid="282" relation="include">
        </childnode>
      </node>
      <node id="270">
        <label>stdlib.h</label>
      </node>
      <node id="272">
        <label>errno.h</label>
      </node>
      <node id="278">
        <label>stddef.h</label>
      </node>
      <node id="267">
        <label>../tools.h</label>
        <link refid="tools_8h_source"/>
        <childnode refid="268" relation="include">
        </childnode>
        <childnode refid="269" relation="include">
        </childnode>
        <childnode refid="270" relation="include">
        </childnode>
        <childnode refid="271" relation="include">
        </childnode>
        <childnode refid="272" relation="include">
        </childnode>
        <childnode refid="273" relation="include">
        </childnode>
        <childnode refid="274" relation="include">
        </childnode>
        <childnode refid="276" relation="include">
        </childnode>
        <childnode refid="279" relation="include">
        </childnode>
      </node>
      <node id="282">
        <label>AsciiFile.h</label>
        <link refid="AsciiFile_8h_source"/>
        <childnode refid="267" relation="include">
        </childnode>
      </node>
      <node id="280">
        <label>comm_header.h</label>
        <link refid="comm__header_8h_source"/>
        <childnode refid="267" relation="include">
        </childnode>
        <childnode refid="281" relation="include">
        </childnode>
      </node>
      <node id="277">
        <label>wchar.h</label>
      </node>
      <node id="268">
        <label>string.h</label>
      </node>
      <node id="266">
        <label>CommBase.h</label>
        <link refid="CommBase_8h_source"/>
        <childnode refid="267" relation="include">
        </childnode>
      </node>
      <node id="279">
        <label>unistd.h</label>
      </node>
      <node id="265">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h</label>
        <link refid="ZMQComm_8h"/>
        <childnode refid="266" relation="include">
        </childnode>
        <childnode refid="280" relation="include">
        </childnode>
      </node>
      <node id="274">
        <label>regex_posix.h</label>
        <link refid="regex__posix_8h_source"/>
        <childnode refid="275" relation="include">
        </childnode>
        <childnode refid="276" relation="include">
        </childnode>
      </node>
      <node id="273">
        <label>time.h</label>
      </node>
      <node id="275">
        <label>regex.h</label>
      </node>
      <node id="269">
        <label>stdio.h</label>
      </node>
    </incdepgraph>
    <invincdepgraph>
      <node id="287">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/PsiInterface.hpp</label>
        <link refid="PsiInterface_8hpp_source"/>
      </node>
      <node id="292">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/ServerComm.h</label>
        <link refid="ServerComm_8h_source"/>
        <childnode refid="284" relation="include">
        </childnode>
      </node>
      <node id="285">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/CisInterface.h</label>
        <link refid="CisInterface_8h_source"/>
        <childnode refid="286" relation="include">
        </childnode>
        <childnode refid="288" relation="include">
        </childnode>
      </node>
      <node id="291">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/RPCComm.h</label>
        <link refid="RPCComm_8h_source"/>
        <childnode refid="284" relation="include">
        </childnode>
      </node>
      <node id="288">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/PsiInterface.h</label>
        <link refid="PsiInterface_8h_source"/>
      </node>
      <node id="283">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h</label>
        <link refid="ZMQComm_8h"/>
        <childnode refid="284" relation="include">
        </childnode>
        <childnode refid="289" relation="include">
        </childnode>
      </node>
      <node id="286">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/CisInterface.hpp</label>
        <link refid="CisInterface_8hpp_source"/>
        <childnode refid="287" relation="include">
        </childnode>
      </node>
      <node id="289">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/DefaultComm.h</label>
        <link refid="DefaultComm_8h_source"/>
        <childnode refid="290" relation="include">
        </childnode>
        <childnode refid="284" relation="include">
        </childnode>
        <childnode refid="291" relation="include">
        </childnode>
        <childnode refid="292" relation="include">
        </childnode>
      </node>
      <node id="290">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/ClientComm.h</label>
        <link refid="ClientComm_8h_source"/>
        <childnode refid="284" relation="include">
        </childnode>
      </node>
      <node id="284">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/communication.h</label>
        <link refid="communication_8h_source"/>
        <childnode refid="285" relation="include">
        </childnode>
        <childnode refid="288" relation="include">
        </childnode>
      </node>
    </invincdepgraph>
      <sectiondef kind="func">
      <memberdef kind="function" id="ZMQComm_8h_1a337df148156c2dc4833ecc84300d61cf" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>void</type>
        <definition>static void zmq_install_error</definition>
        <argsstring>()</argsstring>
        <name>zmq_install_error</name>
        <briefdescription>
<para>Flag for checking if this header has already been included. </para>        </briefdescription>
        <detaileddescription>
<para>Print error message about ZMQ library not being installed. </para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="766" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="766" bodyend="768"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a2fd222c87d58066269b2cbc7ca08a27f" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int free_zmq_comm</definition>
        <argsstring>(comm_t *x)</argsstring>
        <name>free_zmq_comm</name>
        <param>
          <type><ref refid="structcomm__t" kindref="compound">comm_t</ref> *</type>
          <declname>x</declname>
        </param>
        <briefdescription>
<para>Perform deallocation for ZMQ communicator. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">x</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structcomm__t" kindref="compound">comm_t</ref> Pointer to communicator to deallocate. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int 1 if there is and error, 0 otherwise. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="776" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="776" bodyend="779"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a1b5282b77bfa4f6fb43d00b38d57c607" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int new_zmq_address</definition>
        <argsstring>(comm_t *comm)</argsstring>
        <name>new_zmq_address</name>
        <param>
          <type><ref refid="structcomm__t" kindref="compound">comm_t</ref> *</type>
          <declname>comm</declname>
        </param>
        <briefdescription>
<para>Create a new socket. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">comm</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structcomm__t" kindref="compound">comm_t</ref> * Comm structure initialized with new_comm_base. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int -1 if the address could not be created. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="787" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="787" bodyend="790"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a5b8a5dfa817e7457a6656eda1bea6a0e" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int init_zmq_comm</definition>
        <argsstring>(comm_t *comm)</argsstring>
        <name>init_zmq_comm</name>
        <param>
          <type><ref refid="structcomm__t" kindref="compound">comm_t</ref> *</type>
          <declname>comm</declname>
        </param>
        <briefdescription>
<para>Initialize a ZeroMQ communicator. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">comm</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structcomm__t" kindref="compound">comm_t</ref> * Comm structure initialized with init_comm_base. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int -1 if the comm could not be initialized. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="798" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="798" bodyend="801"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a7125eaf4b728483132ad68177c7d9ac2" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int zmq_comm_nmsg</definition>
        <argsstring>(const comm_t x)</argsstring>
        <name>zmq_comm_nmsg</name>
        <param>
          <type>const <ref refid="structcomm__t" kindref="compound">comm_t</ref></type>
          <declname>x</declname>
        </param>
        <briefdescription>
<para>Get number of messages in the comm. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">x</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structcomm__t" kindref="compound">comm_t</ref> Communicator to check. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int Number of messages. -1 indicates an error. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="809" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="809" bodyend="812"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1aaef7b2a44ead0a1cc51bdc12db8c1869" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int zmq_comm_send</definition>
        <argsstring>(const comm_t x, const char *data, const size_t len)</argsstring>
        <name>zmq_comm_send</name>
        <param>
          <type>const <ref refid="structcomm__t" kindref="compound">comm_t</ref></type>
          <declname>x</declname>
        </param>
        <param>
          <type>const char *</type>
          <declname>data</declname>
        </param>
        <param>
          <type>const size_t</type>
          <declname>len</declname>
        </param>
        <briefdescription>
<para>Send a message to the comm. Send a message smaller than CIS_MSG_MAX bytes to an output comm. If the message is larger, it will not be sent. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">x</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structcomm__t" kindref="compound">comm_t</ref> structure that comm should be sent to. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">data</parametername>
</parameternamelist>
<parameterdescription>
<para>character pointer to message that should be sent. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">len</parametername>
</parameternamelist>
<parameterdescription>
<para>size_t length of message to be sent. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int 0 if send succesfull, -1 if send unsuccessful. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="824" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="824" bodyend="827"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a789695e988ee2d5c9a82f199d6119f50" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int zmq_comm_recv</definition>
        <argsstring>(const comm_t x, char **data, const size_t len, const int allow_realloc)</argsstring>
        <name>zmq_comm_recv</name>
        <param>
          <type>const <ref refid="structcomm__t" kindref="compound">comm_t</ref></type>
          <declname>x</declname>
        </param>
        <param>
          <type>char **</type>
          <declname>data</declname>
        </param>
        <param>
          <type>const size_t</type>
          <declname>len</declname>
        </param>
        <param>
          <type>const int</type>
          <declname>allow_realloc</declname>
        </param>
        <briefdescription>
<para>Receive a message from an input comm. Receive a message smaller than CIS_MSG_MAX bytes from an input comm. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">x</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structcomm__t" kindref="compound">comm_t</ref> structure that message should be sent to. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="out">data</parametername>
</parameternamelist>
<parameterdescription>
<para>char ** pointer to allocated buffer where the message should be saved. This should be a malloc&apos;d buffer if allow_realloc is 1. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">len</parametername>
</parameternamelist>
<parameterdescription>
<para>const size_t length of the allocated message buffer in bytes. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">allow_realloc</parametername>
</parameternamelist>
<parameterdescription>
<para>const int If 1, the buffer will be realloced if it is not large enought. Otherwise an error will be returned. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int -1 if message could not be received. Length of the received message if message was received. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="842" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="842" bodyend="846"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a288040a644e53ef3a3d1bd1a84e7e945" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>char *</type>
        <definition>static char* set_reply_send</definition>
        <argsstring>(const comm_t *comm)</argsstring>
        <name>set_reply_send</name>
        <param>
          <type>const <ref refid="structcomm__t" kindref="compound">comm_t</ref> *</type>
          <declname>comm</declname>
        </param>
        <briefdescription>
<para>Add reply socket information to a send comm. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">comm</parametername>
</parameternamelist>
<parameterdescription>
<para>comm_t* Comm that confirmation is for. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>char* Reply socket address. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="854" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="854" bodyend="857"/>
      </memberdef>
      <memberdef kind="function" id="ZMQComm_8h_1a3a61d24a5da652e45beff2a46e88a0a2" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int set_reply_recv</definition>
        <argsstring>(const comm_t *comm, const char *address)</argsstring>
        <name>set_reply_recv</name>
        <param>
          <type>const <ref refid="structcomm__t" kindref="compound">comm_t</ref> *</type>
          <declname>comm</declname>
        </param>
        <param>
          <type>const char *</type>
          <declname>address</declname>
        </param>
        <briefdescription>
<para>Add reply socket information to a recv comm. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">comm</parametername>
</parameternamelist>
<parameterdescription>
<para>comm_t* Comm that confirmation is for. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int Index of the reply socket. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" line="865" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h" bodystart="865" bodyend="868"/>
      </memberdef>
      </sectiondef>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="2"><highlight class="preprocessor">#ifndef<sp/>CISZMQCOMM_H_</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="3"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>CISZMQCOMM_H_</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="4"><highlight class="normal"></highlight></codeline>
<codeline lineno="5"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;CommBase.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="6"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;comm_header.h&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="7"><highlight class="normal"></highlight></codeline>
<codeline lineno="8"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>ZMQINSTALLED</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="9"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;czmq.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="10"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="11"><highlight class="normal"></highlight></codeline>
<codeline lineno="12"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>__cplusplus<sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>C++<sp/>compiler,<sp/>use<sp/>C<sp/>linkage<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="13"><highlight class="normal"></highlight><highlight class="keyword">extern</highlight><highlight class="normal"><sp/></highlight><highlight class="stringliteral">&quot;C&quot;</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="14"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="15"><highlight class="normal"></highlight></codeline>
<codeline lineno="16"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>ZMQINSTALLED</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="17"><highlight class="normal"></highlight></codeline>
<codeline lineno="18"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/>_zmq_rand_seeded<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="19"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/>_last_port_set<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="20"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/>_cisSocketsCreated<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="21"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>_last_port<sp/>=<sp/>49152;</highlight></codeline>
<codeline lineno="22"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>static<sp/>double<sp/>_wait_send_t<sp/>=<sp/>0;<sp/><sp/>//<sp/>0.0001;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="23"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>_reply_msg[100]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;CIS_REPLY&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="24"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>_purge_msg[100]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;CIS_PURGE&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="25"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>_zmq_sleeptime<sp/>=<sp/>10000;</highlight></codeline>
<codeline lineno="26"><highlight class="normal"></highlight></codeline>
<codeline lineno="30"><highlight class="keyword">typedef</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal">zmq_reply_t<sp/>{</highlight></codeline>
<codeline lineno="31"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nsockets;<sp/></highlight></codeline>
<codeline lineno="32"><highlight class="normal"><sp/><sp/>zsock_t<sp/>**sockets;</highlight></codeline>
<codeline lineno="33"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>**addresses;</highlight></codeline>
<codeline lineno="34"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>n_msg;</highlight></codeline>
<codeline lineno="35"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>n_rep;</highlight></codeline>
<codeline lineno="36"><highlight class="normal">}<sp/>zmq_reply_t;</highlight></codeline>
<codeline lineno="37"><highlight class="normal"></highlight></codeline>
<codeline lineno="38"><highlight class="normal"></highlight></codeline>
<codeline lineno="39"><highlight class="normal"></highlight><highlight class="comment">//<sp/>Forward<sp/>declarations</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_nmsg(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x);</highlight></codeline>
<codeline lineno="42"><highlight class="normal"></highlight><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>**data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len,</highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>allow_realloc);</highlight></codeline>
<codeline lineno="45"><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight></codeline>
<codeline lineno="52"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>free_zmq_reply(zmq_reply_t<sp/>*x)<sp/>{</highlight></codeline>
<codeline lineno="54"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="56"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x-&gt;sockets<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="57"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>x-&gt;nsockets;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="58"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x-&gt;sockets[i]<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zsock_destroy(&amp;(x-&gt;sockets[i]));</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>x-&gt;sockets[i]<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="61"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="62"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="63"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free(x-&gt;sockets);</highlight></codeline>
<codeline lineno="64"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x-&gt;addresses<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>x-&gt;nsockets;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x-&gt;addresses[i]<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free(x-&gt;addresses[i]);</highlight></codeline>
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>x-&gt;addresses[i]<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="71"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="72"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free(x-&gt;addresses);</highlight></codeline>
<codeline lineno="73"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/>x-&gt;nsockets<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="77"><highlight class="normal">}</highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight></codeline>
<codeline lineno="84"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>init_zmq_reply(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="86"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)malloc(</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(zmq_reply_t));</highlight></codeline>
<codeline lineno="87"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="88"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;init_zmq_reply(%s):<sp/>Failed<sp/>to<sp/>malloc<sp/>reply.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="89"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="90"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="91"><highlight class="normal"><sp/><sp/>zrep-&gt;nsockets<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="92"><highlight class="normal"><sp/><sp/>zrep-&gt;sockets<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="93"><highlight class="normal"><sp/><sp/>zrep-&gt;addresses<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="94"><highlight class="normal"><sp/><sp/>zrep-&gt;n_msg<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="95"><highlight class="normal"><sp/><sp/>zrep-&gt;n_rep<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="96"><highlight class="normal"><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref><sp/>=<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)zrep;</highlight></codeline>
<codeline lineno="97"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="98"><highlight class="normal">};</highlight></codeline>
<codeline lineno="99"><highlight class="normal"></highlight></codeline>
<codeline lineno="106"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="107"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>find_reply_socket(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*address)<sp/>{</highlight></codeline>
<codeline lineno="108"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="109"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="111"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;find_reply_socket(%s):<sp/>Reply<sp/>structure<sp/>not<sp/>initialized.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-2;</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="116"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>zrep-&gt;nsockets;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strcmp(zrep-&gt;addresses[i],<sp/>address)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>i;</highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="121"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="122"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="123"><highlight class="normal">};</highlight></codeline>
<codeline lineno="124"><highlight class="normal"></highlight></codeline>
<codeline lineno="130"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="131"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>do_reply_send(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="134"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="135"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Reply<sp/>structure<sp/>not<sp/>initialized.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="137"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/>zrep-&gt;n_msg++;</highlight></codeline>
<codeline lineno="139"><highlight class="normal"><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>(zsock_t*)(zrep-&gt;sockets[0]);</highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Socket<sp/>is<sp/>NULL.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Poll</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>address=%s,<sp/>begin&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,</highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;addresses[0]);</highlight></codeline>
<codeline lineno="147"><highlight class="normal"></highlight><highlight class="preprocessor">#if<sp/>defined(__cplusplus)<sp/>&amp;&amp;<sp/>defined(_WIN32)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>There<sp/>seems<sp/>to<sp/>be<sp/>an<sp/>error<sp/>in<sp/>the<sp/>poller<sp/>when<sp/>using<sp/>it<sp/>in<sp/>C++</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/>zpoller_t<sp/>*poller<sp/>=<sp/>zpoller_new(s,<sp/>NULL);</highlight></codeline>
<codeline lineno="151"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!(poller))<sp/>{</highlight></codeline>
<codeline lineno="152"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Could<sp/>not<sp/>create<sp/>poller&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="153"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="155"><highlight class="normal"><sp/><sp/>assert(poller);</highlight></codeline>
<codeline lineno="156"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>waiting<sp/>on<sp/>poller...&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="157"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*p<sp/>=<sp/>zpoller_wait(poller,<sp/>-1);</highlight></codeline>
<codeline lineno="158"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//void<sp/>*p<sp/>=<sp/>zpoller_wait(poller,<sp/>1000);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="159"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>poller<sp/>returned&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);<sp/></highlight></codeline>
<codeline lineno="160"><highlight class="normal"><sp/><sp/>zpoller_destroy(&amp;poller);</highlight></codeline>
<codeline lineno="161"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="162"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zpoller_terminated(poller))<sp/>{</highlight></codeline>
<codeline lineno="163"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Poller<sp/>interrupted&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="164"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zpoller_expired(poller))<sp/>{</highlight></codeline>
<codeline lineno="165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Poller<sp/>expired&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="166"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="167"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Poller<sp/>failed&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="168"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="169"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="170"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="171"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="172"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Receive</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="173"><highlight class="normal"><sp/><sp/>zframe_t<sp/>*msg<sp/>=<sp/>zframe_recv(s);</highlight></codeline>
<codeline lineno="174"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="175"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>did<sp/>not<sp/>receive&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="177"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*msg_data<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)zframe_data(msg);</highlight></codeline>
<codeline lineno="179"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Check<sp/>for<sp/>EOF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>is_purge<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strcmp(msg_data,<sp/>CIS_MSG_EOF)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="182"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>EOF<sp/>received&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;n_msg<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;n_rep<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="185"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-2;</highlight></codeline>
<codeline lineno="186"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strcmp(msg_data,<sp/>_purge_msg)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/>is_purge<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="188"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Send</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>zsock_set_linger(s,<sp/>_zmq_sleeptime);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>zframe_send(&amp;msg,<sp/>s,<sp/>0);</highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Check<sp/>for<sp/>purge<sp/>or<sp/>EOF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="193"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>Error<sp/>sending<sp/>reply<sp/>frame.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="195"><highlight class="normal"><sp/><sp/><sp/><sp/>zframe_destroy(&amp;msg);</highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="197"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(is_purge<sp/>==<sp/>1)<sp/>{</highlight></codeline>
<codeline lineno="198"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>PURGE<sp/>received&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="199"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;n_msg<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="200"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;n_rep<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>do_reply_send(comm);</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;n_rep++;</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_send(%s):<sp/>address=%s,<sp/>end&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;addresses[0]);</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="209"><highlight class="normal">};</highlight></codeline>
<codeline lineno="210"><highlight class="normal"></highlight></codeline>
<codeline lineno="218"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="219"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>do_reply_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>isock,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*msg)<sp/>{</highlight></codeline>
<codeline lineno="220"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="221"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="222"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="223"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>Reply<sp/>structure<sp/>not<sp/>initialized.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="224"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="225"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="226"><highlight class="normal"><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>(zsock_t*)(zrep-&gt;sockets[isock]);</highlight></codeline>
<codeline lineno="227"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="228"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>Socket<sp/>is<sp/>NULL.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="230"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="231"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>address=%s,<sp/>begin&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,</highlight></codeline>
<codeline lineno="232"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;addresses[isock]);</highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/>zframe_t<sp/>*msg_send<sp/>=<sp/>zframe_new(msg,<sp/>strlen(msg));</highlight></codeline>
<codeline lineno="234"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg_send<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="235"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>Error<sp/>creating<sp/>frame.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="236"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="237"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="238"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Send</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>zframe_send(&amp;msg_send,<sp/>s,<sp/>0);</highlight></codeline>
<codeline lineno="240"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>Error<sp/>sending<sp/>confirmation.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/><sp/><sp/>zframe_destroy(&amp;msg_send);</highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strcmp(msg,<sp/>CIS_MSG_EOF)<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="246"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;n_msg<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="247"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;n_rep<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/><sp/><sp/>zsock_set_linger(s,<sp/>_zmq_sleeptime);</highlight></codeline>
<codeline lineno="249"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-2;</highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Receive</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="252"><highlight class="normal"><sp/><sp/>zframe_t<sp/>*msg_recv<sp/>=<sp/>zframe_recv(s);</highlight></codeline>
<codeline lineno="253"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(msg_recv<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>did<sp/>not<sp/>receive&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="255"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="256"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="257"><highlight class="normal"><sp/><sp/>zframe_destroy(&amp;msg_recv);</highlight></codeline>
<codeline lineno="258"><highlight class="normal"><sp/><sp/>zrep-&gt;n_rep++;</highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;do_reply_recv(%s):<sp/>address=%s,<sp/>end&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,</highlight></codeline>
<codeline lineno="260"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>zrep-&gt;addresses[isock]);</highlight></codeline>
<codeline lineno="261"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="262"><highlight class="normal">};</highlight></codeline>
<codeline lineno="263"><highlight class="normal"></highlight></codeline>
<codeline lineno="269"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="270"><highlight class="normal"></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*set_reply_send(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="271"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*out<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="272"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="273"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="274"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="275"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_send(%s):<sp/>Reply<sp/>structure<sp/>not<sp/>initialized.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="276"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="277"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="278"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>socket</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="279"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;nsockets<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="280"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;sockets<sp/>=<sp/>(zsock_t**)malloc(</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(zsock_t*));</highlight></codeline>
<codeline lineno="281"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;sockets<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="282"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_send(%s):<sp/>Error<sp/>mallocing<sp/>sockets.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="283"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="284"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="285"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;nsockets<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="286"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;sockets[0]<sp/>=<sp/>zsock_new(ZMQ_REP);</highlight></codeline>
<codeline lineno="287"><highlight class="normal"><sp/><sp/><sp/><sp/>zsock_set_linger(zrep-&gt;sockets[0],<sp/>0);</highlight></codeline>
<codeline lineno="288"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;sockets[0]<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_send(%s):<sp/>Could<sp/>not<sp/>initialize<sp/>empty<sp/>socket.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="290"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="291"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="292"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="293"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>protocol[50]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;tcp&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="294"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>host[50]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;localhost&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="295"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strcmp(host,<sp/></highlight><highlight class="stringliteral">&quot;localhost&quot;</highlight><highlight class="normal">)<sp/>==<sp/>0)</highlight></codeline>
<codeline lineno="296"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>strcpy(host,<sp/></highlight><highlight class="stringliteral">&quot;127.0.0.1&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="297"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>address[100];</highlight></codeline>
<codeline lineno="298"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(_last_port_set<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="299"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;model_index<sp/>=<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>getenv(</highlight><highlight class="stringliteral">&quot;CIS_MODEL_INDEX&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="300"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>_last_port<sp/>=<sp/>49152<sp/>+<sp/>1000<sp/>*<sp/>atoi(getenv(</highlight><highlight class="stringliteral">&quot;CIS_MODEL_INDEX&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="301"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>_last_port_set<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="302"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;_last_port<sp/>=<sp/>%d&quot;</highlight><highlight class="normal">,<sp/>_last_port);</highlight></codeline>
<codeline lineno="303"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="304"><highlight class="normal"><sp/><sp/><sp/><sp/>sprintf(address,<sp/></highlight><highlight class="stringliteral">&quot;%s://%s:*[%d-]&quot;</highlight><highlight class="normal">,<sp/>protocol,<sp/>host,<sp/>_last_port<sp/>+<sp/>1);</highlight></codeline>
<codeline lineno="305"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>port<sp/>=<sp/>zsock_bind(zrep-&gt;sockets[0],<sp/></highlight><highlight class="stringliteral">&quot;%s&quot;</highlight><highlight class="normal">,<sp/>address);</highlight></codeline>
<codeline lineno="306"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(port<sp/>==<sp/>-1)<sp/>{</highlight></codeline>
<codeline lineno="307"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;check_reply_send(%s):<sp/>Could<sp/>not<sp/>bind<sp/>socket<sp/>to<sp/>address<sp/>=<sp/>%s&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="308"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>address);</highlight></codeline>
<codeline lineno="309"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="310"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="311"><highlight class="normal"><sp/><sp/><sp/><sp/>_last_port<sp/>=<sp/>port;</highlight></codeline>
<codeline lineno="312"><highlight class="normal"><sp/><sp/><sp/><sp/>sprintf(address,<sp/></highlight><highlight class="stringliteral">&quot;%s://%s:%d&quot;</highlight><highlight class="normal">,<sp/>protocol,<sp/>host,<sp/>port);</highlight></codeline>
<codeline lineno="313"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;addresses<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">**)malloc(</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*));</highlight></codeline>
<codeline lineno="314"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;addresses[0]<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)malloc((strlen(address)<sp/>+<sp/>1)*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="315"><highlight class="normal"><sp/><sp/><sp/><sp/>strcpy(zrep-&gt;addresses[0],<sp/>address);</highlight></codeline>
<codeline lineno="316"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;check_reply_send(%s):<sp/>New<sp/>reply<sp/>socket:<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>address);</highlight></codeline>
<codeline lineno="317"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="318"><highlight class="normal"><sp/><sp/>out<sp/>=<sp/>zrep-&gt;addresses[0];</highlight></codeline>
<codeline lineno="319"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="320"><highlight class="normal">};</highlight></codeline>
<codeline lineno="321"><highlight class="normal"></highlight></codeline>
<codeline lineno="327"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="328"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>set_reply_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>address)<sp/>{</highlight></codeline>
<codeline lineno="329"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="331"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="332"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="333"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Reply<sp/>structure<sp/>not<sp/>initialized.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="334"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="335"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="336"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Match<sp/>address<sp/>and<sp/>create<sp/>if<sp/>it<sp/>dosn&apos;t<sp/>exist</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="337"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>isock<sp/>=<sp/>find_reply_socket(comm,<sp/>address);</highlight></codeline>
<codeline lineno="338"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(isock<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="339"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(isock<sp/>==<sp/>-2)<sp/>{</highlight></codeline>
<codeline lineno="340"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Error<sp/>locating<sp/>socket.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="341"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="342"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="343"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Realloc<sp/>arrays</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="344"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;sockets<sp/>=<sp/>(zsock_t**)realloc(zrep-&gt;sockets,</highlight></codeline>
<codeline lineno="345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(zsock_t*)*(zrep-&gt;nsockets<sp/>+<sp/>1));</highlight></codeline>
<codeline lineno="346"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;sockets<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="347"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Error<sp/>reallocing<sp/>sockets.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="348"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="349"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="350"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;addresses<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">**)realloc(zrep-&gt;addresses,</highlight></codeline>
<codeline lineno="351"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)*(zrep-&gt;nsockets<sp/>+<sp/>1));</highlight></codeline>
<codeline lineno="352"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;addresses<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Error<sp/>reallocing<sp/>addresses.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="354"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="356"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>new<sp/>socket</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/><sp/><sp/>isock<sp/>=<sp/>zrep-&gt;nsockets;</highlight></codeline>
<codeline lineno="358"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;nsockets++;</highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;sockets[isock]<sp/>=<sp/>zsock_new(ZMQ_REQ);</highlight></codeline>
<codeline lineno="360"><highlight class="normal"><sp/><sp/><sp/><sp/>zsock_set_linger(zrep-&gt;sockets[isock],<sp/>0);</highlight></codeline>
<codeline lineno="361"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;sockets[isock]<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="362"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Could<sp/>not<sp/>initialize<sp/>empty<sp/>socket.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="363"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="364"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="366"><highlight class="normal"><sp/><sp/><sp/><sp/>zrep-&gt;addresses[isock]<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)malloc(</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">)*(strlen(address)<sp/>+<sp/>1));</highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep-&gt;addresses[isock]<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="368"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Could<sp/>not<sp/>realloc<sp/>new<sp/>address.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="370"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="371"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="372"><highlight class="normal"><sp/><sp/><sp/><sp/>strcpy(zrep-&gt;addresses[isock],<sp/>address);</highlight></codeline>
<codeline lineno="373"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>zsock_connect(zrep-&gt;sockets[isock],<sp/></highlight><highlight class="stringliteral">&quot;%s&quot;</highlight><highlight class="normal">,<sp/>address);</highlight></codeline>
<codeline lineno="374"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="375"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>Could<sp/>not<sp/>connect<sp/>to<sp/>socket.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="376"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="377"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="378"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="379"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;set_reply_recv(%s):<sp/>New<sp/>recv<sp/>socket:<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>address);</highlight></codeline>
<codeline lineno="380"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="381"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>isock;</highlight></codeline>
<codeline lineno="382"><highlight class="normal">};</highlight></codeline>
<codeline lineno="383"><highlight class="normal"></highlight></codeline>
<codeline lineno="391"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="392"><highlight class="normal"></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>check_reply_send(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>len,</highlight></codeline>
<codeline lineno="393"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*new_len)<sp/>{</highlight></codeline>
<codeline lineno="394"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*out<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)malloc(len<sp/>+<sp/>1);</highlight></codeline>
<codeline lineno="395"><highlight class="normal"><sp/><sp/>memcpy(out,<sp/>data,<sp/>len<sp/>+<sp/>1);</highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/>new_len[0]<sp/>=<sp/>len;</highlight></codeline>
<codeline lineno="397"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="398"><highlight class="normal">};</highlight></codeline>
<codeline lineno="399"><highlight class="normal"></highlight></codeline>
<codeline lineno="400"><highlight class="normal"></highlight></codeline>
<codeline lineno="409"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="410"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>check_reply_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len)<sp/>{</highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>new_len<sp/>=<sp/>(int)len;</highlight></codeline>
<codeline lineno="412"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="413"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(comm-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;check_reply_recv(%s):<sp/>Reply<sp/>structure<sp/>not<sp/>initialized.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="419"><highlight class="normal"><sp/><sp/>zrep-&gt;n_msg++;</highlight></codeline>
<codeline lineno="420"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Extract<sp/>address</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/><ref refid="structcomm__head__t" kindref="compound">comm_head_t</ref><sp/>head<sp/>=<sp/>parse_comm_header(data,<sp/>len);</highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>address[100];</highlight></codeline>
<codeline lineno="423"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>address_len;</highlight></codeline>
<codeline lineno="424"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((comm-&gt;<ref refid="structcomm__t_1a9b44169ff04756e8802bb2510892cf56" kindref="member">is_work_comm</ref><sp/>==<sp/>1)<sp/>&amp;&amp;<sp/>(zrep-&gt;nsockets<sp/>==<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="425"><highlight class="normal"><sp/><sp/><sp/><sp/>address_len<sp/>=<sp/>strlen(zrep-&gt;addresses[0]);</highlight></codeline>
<codeline lineno="426"><highlight class="normal"><sp/><sp/><sp/><sp/>memcpy(address,<sp/>zrep-&gt;addresses[0],<sp/>address_len);</highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strlen(head.<ref refid="structcomm__head__t_1a81034ab274964279115f5ce7669f055b" kindref="member">zmq_reply</ref>)<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="428"><highlight class="normal"><sp/><sp/><sp/><sp/>address_len<sp/>=<sp/>strlen(head.<ref refid="structcomm__head__t_1a81034ab274964279115f5ce7669f055b" kindref="member">zmq_reply</ref>);</highlight></codeline>
<codeline lineno="429"><highlight class="normal"><sp/><sp/><sp/><sp/>memcpy(address,<sp/>head.<ref refid="structcomm__head__t_1a81034ab274964279115f5ce7669f055b" kindref="member">zmq_reply</ref>,<sp/>address_len);</highlight></codeline>
<codeline lineno="430"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="431"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;check_reply_recv(%s):<sp/>Error<sp/>parsing<sp/>reply<sp/>header<sp/>in<sp/>&apos;%s&apos;&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>data);</highlight></codeline>
<codeline lineno="433"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="434"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="435"><highlight class="normal"><sp/><sp/>address[address_len]<sp/>=<sp/></highlight><highlight class="charliteral">&apos;\0&apos;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="436"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Match<sp/>address<sp/>and<sp/>create<sp/>if<sp/>it<sp/>dosn&apos;t<sp/>exist</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="437"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>isock<sp/>=<sp/>set_reply_recv(comm,<sp/>address);</highlight></codeline>
<codeline lineno="438"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(isock<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="439"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;check_reply_recv(%s):<sp/>Error<sp/>setting<sp/>reply<sp/>socket.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="440"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="441"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="442"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Confirm<sp/>message<sp/>receipt</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="443"><highlight class="normal"><sp/><sp/>ret<sp/>=<sp/>do_reply_recv(comm,<sp/>isock,<sp/>_reply_msg);</highlight></codeline>
<codeline lineno="444"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;check_reply_recv(%s):<sp/>Error<sp/>during<sp/>reply.&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="446"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="447"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="448"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>new_len;</highlight></codeline>
<codeline lineno="449"><highlight class="normal">};</highlight></codeline>
<codeline lineno="450"><highlight class="normal"></highlight></codeline>
<codeline lineno="456"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="457"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>new_zmq_address(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>Get<sp/>protocol/host<sp/>from<sp/>input</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="459"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>protocol[50]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;tcp&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="460"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>host[50]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;localhost&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="461"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>address[100];</highlight></codeline>
<codeline lineno="462"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strcmp(host,<sp/></highlight><highlight class="stringliteral">&quot;localhost&quot;</highlight><highlight class="normal">)<sp/>==<sp/>0)</highlight></codeline>
<codeline lineno="463"><highlight class="normal"><sp/><sp/><sp/><sp/>strcpy(host,<sp/></highlight><highlight class="stringliteral">&quot;127.0.0.1&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="464"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((strcmp(protocol,<sp/></highlight><highlight class="stringliteral">&quot;inproc&quot;</highlight><highlight class="normal">)<sp/>==<sp/>0)<sp/>||</highlight></codeline>
<codeline lineno="465"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(strcmp(protocol,<sp/></highlight><highlight class="stringliteral">&quot;ipc&quot;</highlight><highlight class="normal">)<sp/>==<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="466"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>small<sp/>chance<sp/>of<sp/>reusing<sp/>same<sp/>number</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="467"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>key<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="468"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!(_zmq_rand_seeded))<sp/>{</highlight></codeline>
<codeline lineno="469"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>srand(ptr2seed(comm));</highlight></codeline>
<codeline lineno="470"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>_zmq_rand_seeded<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="471"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="472"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(key<sp/>==<sp/>0)<sp/>key<sp/>=<sp/>rand();</highlight></codeline>
<codeline lineno="473"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strlen(comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>)<sp/>==<sp/>0)</highlight></codeline>
<codeline lineno="474"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sprintf(comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/></highlight><highlight class="stringliteral">&quot;tempnewZMQ-%d&quot;</highlight><highlight class="normal">,<sp/>key);</highlight></codeline>
<codeline lineno="475"><highlight class="normal"><sp/><sp/><sp/><sp/>sprintf(address,<sp/></highlight><highlight class="stringliteral">&quot;%s://%s&quot;</highlight><highlight class="normal">,<sp/>protocol,<sp/>comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="476"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="477"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(_last_port_set<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="478"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;model_index<sp/>=<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>getenv(</highlight><highlight class="stringliteral">&quot;CIS_MODEL_INDEX&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="479"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>_last_port<sp/>=<sp/>49152<sp/>+<sp/>1000<sp/>*<sp/>atoi(getenv(</highlight><highlight class="stringliteral">&quot;CIS_MODEL_INDEX&quot;</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="480"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>_last_port_set<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="481"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;_last_port<sp/>=<sp/>%d&quot;</highlight><highlight class="normal">,<sp/>_last_port);</highlight></codeline>
<codeline lineno="482"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="483"><highlight class="normal"><sp/><sp/><sp/>sprintf(address,<sp/></highlight><highlight class="stringliteral">&quot;%s://%s:*[%d-]&quot;</highlight><highlight class="normal">,<sp/>protocol,<sp/>host,<sp/>_last_port<sp/>+<sp/>1);</highlight></codeline>
<codeline lineno="484"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>strcat(address,<sp/>&quot;:!&quot;);<sp/>//<sp/>For<sp/>random<sp/>port<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="485"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="486"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Bind</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="487"><highlight class="normal"><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>zsock_new(ZMQ_PAIR);</highlight></codeline>
<codeline lineno="488"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="489"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;new_zmq_address:<sp/>Could<sp/>not<sp/>initialize<sp/>empty<sp/>socket.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="490"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="491"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="492"><highlight class="normal"><sp/><sp/>zsock_set_linger(s,<sp/>0);</highlight></codeline>
<codeline lineno="493"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>port<sp/>=<sp/>zsock_bind(s,<sp/></highlight><highlight class="stringliteral">&quot;%s&quot;</highlight><highlight class="normal">,<sp/>address);</highlight></codeline>
<codeline lineno="494"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(port<sp/>==<sp/>-1)<sp/>{</highlight></codeline>
<codeline lineno="495"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;new_zmq_address:<sp/>Could<sp/>not<sp/>bind<sp/>socket<sp/>to<sp/>address<sp/>=<sp/>%s&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="496"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>address);</highlight></codeline>
<codeline lineno="497"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="498"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="499"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Add<sp/>port<sp/>to<sp/>address</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="500"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((strcmp(protocol,<sp/></highlight><highlight class="stringliteral">&quot;inproc&quot;</highlight><highlight class="normal">)<sp/>!=<sp/>0)<sp/>&amp;&amp;</highlight></codeline>
<codeline lineno="501"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(strcmp(protocol,<sp/></highlight><highlight class="stringliteral">&quot;ipc&quot;</highlight><highlight class="normal">)<sp/>!=<sp/>0))<sp/>{</highlight></codeline>
<codeline lineno="502"><highlight class="normal"><sp/><sp/><sp/><sp/>_last_port<sp/>=<sp/>port;</highlight></codeline>
<codeline lineno="503"><highlight class="normal"><sp/><sp/><sp/><sp/>sprintf(address,<sp/></highlight><highlight class="stringliteral">&quot;%s://%s:%d&quot;</highlight><highlight class="normal">,<sp/>protocol,<sp/>host,<sp/>port);</highlight></codeline>
<codeline lineno="504"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="505"><highlight class="normal"><sp/><sp/>strcpy(comm-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>,<sp/>address);</highlight></codeline>
<codeline lineno="506"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;new_zmq_address:<sp/>Bound<sp/>socket<sp/>to<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>);</highlight></codeline>
<codeline lineno="507"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strlen(comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>)<sp/>==<sp/>0)</highlight></codeline>
<codeline lineno="508"><highlight class="normal"><sp/><sp/><sp/><sp/>sprintf(comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/></highlight><highlight class="stringliteral">&quot;tempnewZMQ-%d&quot;</highlight><highlight class="normal">,<sp/>port);</highlight></codeline>
<codeline lineno="509"><highlight class="normal"><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref><sp/>=<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)s;</highlight></codeline>
<codeline lineno="510"><highlight class="normal"><sp/><sp/>_cisSocketsCreated++;</highlight></codeline>
<codeline lineno="511"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Init<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="512"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>init_zmq_reply(comm);</highlight></codeline>
<codeline lineno="513"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="514"><highlight class="normal">};</highlight></codeline>
<codeline lineno="515"><highlight class="normal"></highlight></codeline>
<codeline lineno="521"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="522"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>init_zmq_comm(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="523"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="524"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(comm-&gt;<ref refid="structcomm__t_1afe8a58007e764fb3f2e906025f89fe72" kindref="member">valid</ref><sp/>==<sp/>0)</highlight></codeline>
<codeline lineno="525"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="526"><highlight class="normal"><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>zsock_new(ZMQ_PAIR);</highlight></codeline>
<codeline lineno="527"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="528"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;init_zmq_address:<sp/>Could<sp/>not<sp/>initialize<sp/>empty<sp/>socket.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="529"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="530"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="531"><highlight class="normal"><sp/><sp/>zsock_set_linger(s,<sp/>0);</highlight></codeline>
<codeline lineno="532"><highlight class="normal"><sp/><sp/>ret<sp/>=<sp/>zsock_connect(s,<sp/></highlight><highlight class="stringliteral">&quot;%s&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>);</highlight></codeline>
<codeline lineno="533"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>==<sp/>-1)<sp/>{</highlight></codeline>
<codeline lineno="534"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;init_zmq_address:<sp/>Could<sp/>not<sp/>connect<sp/>socket<sp/>to<sp/>address<sp/>=<sp/>%s&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="535"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>);</highlight></codeline>
<codeline lineno="536"><highlight class="normal"><sp/><sp/><sp/><sp/>zsock_destroy(&amp;s);</highlight></codeline>
<codeline lineno="537"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="538"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="539"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;init_zmq_address:<sp/>Connected<sp/>socket<sp/>to<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>);</highlight></codeline>
<codeline lineno="540"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(strlen(comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>)<sp/>==<sp/>0)</highlight></codeline>
<codeline lineno="541"><highlight class="normal"><sp/><sp/><sp/><sp/>sprintf(comm-&gt;<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/></highlight><highlight class="stringliteral">&quot;tempinitZMQ-%s&quot;</highlight><highlight class="normal">,<sp/>comm-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>);</highlight></codeline>
<codeline lineno="542"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Asign<sp/>to<sp/>void<sp/>pointer</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="543"><highlight class="normal"><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref><sp/>=<sp/>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">*)s;</highlight></codeline>
<codeline lineno="544"><highlight class="normal"><sp/><sp/>ret<sp/>=<sp/>init_zmq_reply(comm);</highlight></codeline>
<codeline lineno="545"><highlight class="normal"><sp/><sp/>comm-&gt;<ref refid="structcomm__t_1a9810578a787d8503b00bcb78a592073d" kindref="member">always_send_header</ref><sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="546"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="547"><highlight class="normal">};</highlight></codeline>
<codeline lineno="548"><highlight class="normal"></highlight></codeline>
<codeline lineno="554"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="555"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>free_zmq_comm(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*x)<sp/>{</highlight></codeline>
<codeline lineno="556"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="557"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x<sp/>==<sp/>NULL)</highlight></codeline>
<codeline lineno="558"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="559"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Drain<sp/>input</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="560"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((is_recv(x-&gt;<ref refid="structcomm__t_1a1940bbad161f8cf5f868ff4cf4e95cda" kindref="member">direction</ref>))<sp/>&amp;&amp;<sp/>(x-&gt;<ref refid="structcomm__t_1afe8a58007e764fb3f2e906025f89fe72" kindref="member">valid</ref><sp/>==<sp/>1))<sp/>{</highlight></codeline>
<codeline lineno="561"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(_cis_error_flag<sp/>==<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="562"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>data_len<sp/>=<sp/>100;</highlight></codeline>
<codeline lineno="563"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*data<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)malloc(data_len);</highlight></codeline>
<codeline lineno="564"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(zmq_comm_nmsg(*x)<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="565"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>zmq_comm_recv(*x,<sp/>&amp;data,<sp/>data_len,<sp/>1);</highlight></codeline>
<codeline lineno="566"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="567"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>==<sp/>-2)<sp/>{</highlight></codeline>
<codeline lineno="568"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>x-&gt;<ref refid="structcomm__t_1a1d7418e5f54be56939a7f26b68a55f3d" kindref="member">recv_eof</ref>[0]<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="569"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="570"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="571"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="572"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="573"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free(data);</highlight></codeline>
<codeline lineno="574"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="575"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="576"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Free<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="577"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="578"><highlight class="normal"><sp/><sp/><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(x-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="579"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Free<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="580"><highlight class="normal"><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>free_zmq_reply(zrep);</highlight></codeline>
<codeline lineno="581"><highlight class="normal"><sp/><sp/><sp/><sp/>free(x-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="582"><highlight class="normal"><sp/><sp/><sp/><sp/>x-&gt;<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="583"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="584"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x-&gt;<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="585"><highlight class="normal"><sp/><sp/><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>(zsock_t*)(x-&gt;<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref>);</highlight></codeline>
<codeline lineno="586"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="587"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;Destroying<sp/>socket:<sp/>%s&quot;</highlight><highlight class="normal">,<sp/>x-&gt;<ref refid="structcomm__t_1aca2bf1fc2b62c779c50848501f31fbf0" kindref="member">address</ref>);</highlight></codeline>
<codeline lineno="588"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zsock_destroy(&amp;s);</highlight></codeline>
<codeline lineno="589"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="590"><highlight class="normal"><sp/><sp/><sp/><sp/>x-&gt;<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="591"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="592"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="593"><highlight class="normal">};</highlight></codeline>
<codeline lineno="594"><highlight class="normal"></highlight></codeline>
<codeline lineno="600"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="601"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_nmsg(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x)<sp/>{</highlight></codeline>
<codeline lineno="602"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>out<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="603"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(is_recv(x.<ref refid="structcomm__t_1a1940bbad161f8cf5f868ff4cf4e95cda" kindref="member">direction</ref>))<sp/>{</highlight></codeline>
<codeline lineno="604"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x.<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="605"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>(zsock_t*)(x.<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref>);</highlight></codeline>
<codeline lineno="606"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zpoller_t<sp/>*poller<sp/>=<sp/>zpoller_new(s,<sp/>NULL);</highlight></codeline>
<codeline lineno="607"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(poller<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="608"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_nmsg:<sp/>Could<sp/>not<sp/>create<sp/>poller&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="609"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="610"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="611"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>*p<sp/>=<sp/>zpoller_wait(poller,<sp/>1);</highlight></codeline>
<codeline lineno="612"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="613"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zpoller_terminated(poller))<sp/>{</highlight></codeline>
<codeline lineno="614"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_nmsg:<sp/>Poller<sp/>interrupted&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="615"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="616"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="617"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="618"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="619"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="620"><highlight class="normal"><sp/><sp/><sp/><sp/>out<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="621"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="622"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zpoller_destroy(&amp;poller);</highlight></codeline>
<codeline lineno="623"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="624"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="625"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>(x.last_send[0]<sp/>!=<sp/>0)<sp/>{<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="626"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>time_t<sp/>now;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="627"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>time(&amp;now);<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="628"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>double<sp/>elapsed<sp/>=<sp/>difftime(now,<sp/>x.last_send[0]);<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="629"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>if<sp/>(elapsed<sp/>&gt;<sp/>_wait_send_t)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="630"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/>out<sp/>=<sp/>0;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="631"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>else<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="632"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/>out<sp/>=<sp/>1;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="633"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>}<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="634"><highlight class="normal"><sp/><sp/><sp/><sp/>zmq_reply_t<sp/>*zrep<sp/>=<sp/>(zmq_reply_t*)(x.<ref refid="structcomm__t_1a05095fa4451ed9085e2d23bb5304df10" kindref="member">reply</ref>);</highlight></codeline>
<codeline lineno="635"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zrep<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="636"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_nmsg(%s):<sp/>nmsg<sp/>=<sp/>%d,<sp/>nrep<sp/>=<sp/>%d&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="637"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>zrep-&gt;n_msg,<sp/>zrep-&gt;n_rep);</highlight></codeline>
<codeline lineno="638"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>zrep-&gt;n_msg<sp/>-<sp/>zrep-&gt;n_rep;</highlight></codeline>
<codeline lineno="639"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="640"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="641"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="642"><highlight class="normal">};</highlight></codeline>
<codeline lineno="643"><highlight class="normal"></highlight></codeline>
<codeline lineno="653"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="654"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_send(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len)<sp/>{</highlight></codeline>
<codeline lineno="655"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>%d<sp/>bytes&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>len);</highlight></codeline>
<codeline lineno="656"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(comm_base_send(x,<sp/>data,<sp/>len)<sp/>==<sp/>-1)</highlight></codeline>
<codeline lineno="657"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="658"><highlight class="normal"><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>(zsock_t*)(x.<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref>);</highlight></codeline>
<codeline lineno="659"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="660"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>socket<sp/>handle<sp/>is<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="661"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="662"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="663"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>new_len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="664"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*new_data<sp/>=<sp/>check_reply_send(&amp;x,<sp/>data,<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)len,<sp/>&amp;new_len);</highlight></codeline>
<codeline lineno="665"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(new_data<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="666"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>Adding<sp/>reply<sp/>address<sp/>failed.&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="667"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="668"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="669"><highlight class="normal"><sp/><sp/>zframe_t<sp/>*f<sp/>=<sp/>zframe_new(new_data,<sp/>new_len);</highlight></codeline>
<codeline lineno="670"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="671"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(f<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="672"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>frame<sp/>handle<sp/>is<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="673"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="674"><highlight class="normal"><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>zframe_send(&amp;f,<sp/>s,<sp/>0);</highlight></codeline>
<codeline lineno="675"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="676"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>Error<sp/>in<sp/>zframe_send&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="677"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zframe_destroy(&amp;f);</highlight></codeline>
<codeline lineno="678"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="679"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="680"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>reply</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="681"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&gt;=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="682"><highlight class="normal"><sp/><sp/><sp/><sp/>ret<sp/>=<sp/>do_reply_send(&amp;x);</highlight></codeline>
<codeline lineno="683"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="684"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>==<sp/>-2)<sp/>{</highlight></codeline>
<codeline lineno="685"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>EOF<sp/>received&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="686"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="687"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>Error<sp/>in<sp/>do_reply_send&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="688"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="689"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="690"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="691"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_send(%s):<sp/>returning<sp/>%d&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>ret);</highlight></codeline>
<codeline lineno="692"><highlight class="normal"><sp/><sp/>free(new_data);</highlight></codeline>
<codeline lineno="693"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="694"><highlight class="normal">};</highlight></codeline>
<codeline lineno="695"><highlight class="normal"></highlight></codeline>
<codeline lineno="708"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="709"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>**data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len,</highlight></codeline>
<codeline lineno="710"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>allow_realloc)<sp/>{</highlight></codeline>
<codeline lineno="711"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s)&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="712"><highlight class="normal"><sp/><sp/>zsock_t<sp/>*s<sp/>=<sp/>(zsock_t*)(x.<ref refid="structcomm__t_1ab7b58a54178acddc3f641e3a285aab7f" kindref="member">handle</ref>);</highlight></codeline>
<codeline lineno="713"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="714"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>socket<sp/>handle<sp/>is<sp/>NULL&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="715"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="716"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="717"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(1)<sp/>{</highlight></codeline>
<codeline lineno="718"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nmsg<sp/>=<sp/>zmq_comm_nmsg(x);</highlight></codeline>
<codeline lineno="719"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(nmsg<sp/>&lt;<sp/>0)<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="720"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(nmsg<sp/>&gt;<sp/>0)<sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="721"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="722"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>no<sp/>messages,<sp/>sleep&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="723"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>usleep(CIS_SLEEP_TIME);</highlight></codeline>
<codeline lineno="724"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="725"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="726"><highlight class="normal"><sp/><sp/>zframe_t<sp/>*out<sp/>=<sp/>zframe_recv(s);</highlight></codeline>
<codeline lineno="727"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="728"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>did<sp/>not<sp/>receive&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="729"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="730"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="731"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len_recv<sp/>=<sp/>zframe_size(out)<sp/>+<sp/>1;</highlight></codeline>
<codeline lineno="732"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(len_recv<sp/>&gt;<sp/>len)<sp/>{</highlight></codeline>
<codeline lineno="733"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(allow_realloc)<sp/>{</highlight></codeline>
<codeline lineno="734"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>reallocating<sp/>buffer<sp/>from<sp/>%d<sp/>to<sp/>%d<sp/>bytes.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="735"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>len,<sp/>len_recv);</highlight></codeline>
<codeline lineno="736"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>(*data)<sp/>=<sp/>(</highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*)realloc(*data,<sp/>len_recv);</highlight></codeline>
<codeline lineno="737"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(*data<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="738"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>failed<sp/>to<sp/>realloc<sp/>buffer.&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>);</highlight></codeline>
<codeline lineno="739"><highlight class="normal"><sp/><sp/><sp/><sp/>zframe_destroy(&amp;out);</highlight></codeline>
<codeline lineno="740"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="741"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="742"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="743"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>buffer<sp/>(%d<sp/>bytes)<sp/>is<sp/>not<sp/>large<sp/>enough<sp/>for<sp/>message<sp/>(%d<sp/>bytes)&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="744"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>len,<sp/>len_recv);</highlight></codeline>
<codeline lineno="745"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>zframe_destroy(&amp;out);</highlight></codeline>
<codeline lineno="746"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-((int)(len_recv<sp/>-<sp/>1));</highlight></codeline>
<codeline lineno="747"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="748"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="749"><highlight class="normal"><sp/><sp/>memcpy(*data,<sp/>zframe_data(out),<sp/>len_recv);</highlight></codeline>
<codeline lineno="750"><highlight class="normal"><sp/><sp/>(*data)[len_recv-1]<sp/>=<sp/></highlight><highlight class="charliteral">&apos;\0&apos;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="751"><highlight class="normal"><sp/><sp/>zframe_destroy(&amp;out);</highlight></codeline>
<codeline lineno="752"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>(int)len_recv<sp/>-<sp/>1;</highlight></codeline>
<codeline lineno="753"><highlight class="normal"><sp/><sp/>ret<sp/>=<sp/>check_reply_recv(&amp;x,<sp/>*data,<sp/>(</highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal">)ret);</highlight></codeline>
<codeline lineno="754"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;zmq_comm_recv(%s):<sp/>returning<sp/>%d&quot;</highlight><highlight class="normal">,<sp/>x.<ref refid="structcomm__t_1a0c8b237f48a50a181eab8447a87ec172" kindref="member">name</ref>,<sp/>ret);</highlight></codeline>
<codeline lineno="755"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ret;</highlight></codeline>
<codeline lineno="756"><highlight class="normal">};</highlight></codeline>
<codeline lineno="757"><highlight class="normal"></highlight></codeline>
<codeline lineno="758"><highlight class="normal"></highlight></codeline>
<codeline lineno="759"><highlight class="normal"></highlight><highlight class="comment">//<sp/>Definitions<sp/>in<sp/>the<sp/>case<sp/>where<sp/>ZMQ<sp/>libraries<sp/>not<sp/>installed</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="760"><highlight class="normal"></highlight><highlight class="preprocessor">#else<sp/></highlight><highlight class="comment">/*ZMQINSTALLED*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="761"><highlight class="normal"></highlight></codeline>
<codeline lineno="765"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="766"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>zmq_install_error()<sp/>{</highlight></codeline>
<codeline lineno="767"><highlight class="normal"><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;Compiler<sp/>flag<sp/>&apos;ZMQINSTALLED&apos;<sp/>not<sp/>defined<sp/>so<sp/>ZMQ<sp/>bindings<sp/>are<sp/>disabled.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="768"><highlight class="normal">};</highlight></codeline>
<codeline lineno="769"><highlight class="normal"></highlight></codeline>
<codeline lineno="775"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="776"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>free_zmq_comm(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*x)<sp/>{</highlight></codeline>
<codeline lineno="777"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="778"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>1;</highlight></codeline>
<codeline lineno="779"><highlight class="normal">};</highlight></codeline>
<codeline lineno="780"><highlight class="normal"></highlight></codeline>
<codeline lineno="786"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="787"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>new_zmq_address(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="788"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="789"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="790"><highlight class="normal">};</highlight></codeline>
<codeline lineno="791"><highlight class="normal"></highlight></codeline>
<codeline lineno="797"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="798"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>init_zmq_comm(<ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="799"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="800"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="801"><highlight class="normal">};</highlight></codeline>
<codeline lineno="802"><highlight class="normal"></highlight></codeline>
<codeline lineno="808"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="809"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_nmsg(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x)<sp/>{</highlight></codeline>
<codeline lineno="810"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="811"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="812"><highlight class="normal">};</highlight></codeline>
<codeline lineno="813"><highlight class="normal"></highlight></codeline>
<codeline lineno="823"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="824"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_send(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len)<sp/>{</highlight></codeline>
<codeline lineno="825"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="826"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="827"><highlight class="normal">};</highlight></codeline>
<codeline lineno="828"><highlight class="normal"></highlight></codeline>
<codeline lineno="841"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="842"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>zmq_comm_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>x,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>**data,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>len,</highlight></codeline>
<codeline lineno="843"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>allow_realloc)<sp/>{</highlight></codeline>
<codeline lineno="844"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="845"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="846"><highlight class="normal">};</highlight></codeline>
<codeline lineno="847"><highlight class="normal"></highlight></codeline>
<codeline lineno="853"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="854"><highlight class="normal"></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*set_reply_send(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm)<sp/>{</highlight></codeline>
<codeline lineno="855"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="856"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>NULL;</highlight></codeline>
<codeline lineno="857"><highlight class="normal">};</highlight></codeline>
<codeline lineno="858"><highlight class="normal"></highlight></codeline>
<codeline lineno="864"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="865"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>set_reply_recv(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structcomm__t" kindref="compound">comm_t</ref><sp/>*comm,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>address)<sp/>{</highlight></codeline>
<codeline lineno="866"><highlight class="normal"><sp/><sp/>zmq_install_error();</highlight></codeline>
<codeline lineno="867"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="868"><highlight class="normal">};</highlight></codeline>
<codeline lineno="869"><highlight class="normal"></highlight></codeline>
<codeline lineno="870"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*ZMQINSTALLED*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="871"><highlight class="normal"></highlight></codeline>
<codeline lineno="872"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>__cplusplus<sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>C++<sp/>compiler,<sp/>end<sp/>C<sp/>linkage<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="873"><highlight class="normal">}</highlight></codeline>
<codeline lineno="874"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="875"><highlight class="normal"></highlight></codeline>
<codeline lineno="876"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*CISZMQCOMM_H_*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="/root/cis_interface/cis_interface/cis_interface/communication/ZMQComm.h"/>
  </compounddef>
</doxygen>
