title: Using ZeroMQ ZMQ_STREAM to be a tcp client. Why am I receiving extra info?
body: <p>I have an application that uses ZeroMQ for various things and I want to also use it as a tcp-client for other external connections.  </p>
  
  <p>Currently if the external tcp-server sends data, the client receives 5 byte id, 0 bytes, 5 bytes, and then actual message.  </p>
  
  <p><strong>How do I get ZeroMQ not to send this stuff?</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;zmq.h&gt;
  #include &lt;cstring&gt;
  #include &lt;assert.h&gt;
  #include &lt;chrono&gt;
  #include &lt;thread&gt;
  
  
  int main()
  {
    void *mpSocketContext = zmq_ctx_new();
  
    /* Create ZMQ_STREAM socket */
    void *mpSerialSocket = zmq_socket(mpSocketContext, ZMQ_STREAM);
    void *mpSocket = mpSerialSocket;
    bool aeBlocking = true;
  
    std::string asAddress = "127.0.0.1:1236";
    asAddress  = "tcp://" + asAddress;
  
    std::cout &lt;&lt; "tcSerialServerPort::tcSerialServerPort: connecting to " &lt;&lt; asAddress &lt;&lt; std::endl;
  
    int rc = zmq_connect(mpSerialSocket, asAddress.c_str());
    if (rc != 0)
      std::cout &lt;&lt; "ZMQ ERROR: zmq_connect " &lt;&lt;  zmq_strerror(zmq_errno()) &lt;&lt; std::endl;
  
    uint8_t id [256];
    size_t id_size = 256;
    rc = zmq_getsockopt (mpSerialSocket, ZMQ_IDENTITY, id, &amp;id_size);
    assert(rc == 0);
  
    while(true)
    {
    zmq_msg_t msg;
    zmq_msg_init(&amp;msg);
    size_t lnBytesReceived = 0;
    std::string lsStr;
  
    lnBytesReceived = zmq_recvmsg(mpSocket, &amp;msg, aeBlocking ? 0 : ZMQ_DONTWAIT);
  
    lsStr = std::string(static_cast&lt;const char*&gt;(zmq_msg_data(&amp;msg)),
        zmq_msg_size(&amp;msg));
  
  
    std::cout &lt;&lt; "Received Bytes=" &lt;&lt; lsStr.size() &lt;&lt; " Data=" &lt;&lt; lsStr &lt;&lt; std::endl;
  
    zmq_msg_close(&amp;msg);
  
    std::this_thread::sleep_for(std::chrono::seconds(1));
    }
  
  
    zmq_close(mpSerialSocket);
    zmq_ctx_destroy(mpSocketContext);
  
    return 0;
  }
  </code></pre>