title: ZeroMQ - Get user ID from ZeroMQ Auth response
body: <p>In ZeroMQ, more precisely cppzmq in my case, when you use ZAP,
  it is handled completely transparently for the user.</p>
  <p>However, as documented in the RFC: <a href="https://rfc.zeromq.org/spec/27/" rel="nofollow noreferrer">https://rfc.zeromq.org/spec/27/</a>,
  the Auth server can send back a user ID and some metadata in the response:</p>
  <blockquote>
  <p>The reply message SHALL consist of the following message frames:</p>
  <ul>
  <li>An address delimiter frame, which SHALL have a length of zero.</li>
  <li>The version frame, which SHALL contain the three octets “1.0”.</li>
  <li>The request id, which MAY contain an opaque binary blob.</li>
  <li>The status code, which SHALL contain a string.</li>
  <li>The status text, which MAY contain a string.</li>
  <li><em>The user id, which SHALL contain a string.</em></li>
  <li>The metadata, which MAY contain a blob.</li>
  </ul>
  </blockquote>
  <p>A little bit further down, it precises the meaning of <em>user id</em>:</p>
  <blockquote>
  <p><em>user id</em>: this MAY provide the user identity in case of a 200 status, for use by applications. For other statuses, it SHALL be empty.</p>
  </blockquote>
  <p><strong>My question is the following: how can you retrieve the user ID from the response with cppzmq?</strong></p>
  <p>Small code example to show what I mean:</p>
  <pre class="lang-cpp prettyprint-override"><code>void client() {
    zmq::context_t context;
    zmq::socket_t socket (context, zmq::socket_type::req);
    socket.set(zmq::sockopt::zap_domain, &quot;global&quot;);
    socket.set(zmq::sockopt::plain_username, &quot;user&quot;);
    socket.set(zmq::sockopt::plain_password, &quot;password&quot;);
  
    socket.connect(&quot;tcp://127.0.0.1:4242&quot;);
    ...
    std::string auth_user_id = /* magic function here */;
  
  }
  </code></pre>