ZeroMq recv not blocking
<p>I'm attempting to learn ZeroMq for  project at work although my background is in C#, and in the most simplest of tests I seem to have an issue where the <code>socket.recv(...)</code> call will block for the first received message, but after this throws an exception because the amount of data received is -1.</p>

<p>Currently my 'server' is:</p>

<pre><code>zmq::context_t context(1);
zmq::socket_t socket(context, ZMQ_REP);
socket.bind("tcp://127.0.0.1:5555");

while (true)
{
    zmq::message_t message;
    if (socket.recv(&amp;message))
    {
        auto str = std::string(static_cast&lt;char*&gt;(message.data()), message.size());
        printf("Receieved: %s\n", str.c_str());
    }
}
</code></pre>

<p>This is basically from following the first example server within the ZeroMq documentation.</p>

<p>I'm pushing <strong>1</strong> bit of data from a C# 'client' using this code:</p>

<pre><code>using (var context = new ZContext())
using (var requester = new ZSocket(context, ZSocketType.REQ))
{
    requester.Connect(@"tcp://127.0.0.1:5555");
    requester.Send(new ZFrame(@"hello"));

    requester.Disconnect(@"tcp://127.0.0.1:5555");
}
</code></pre>

<p>Now I start the server, then start the client. I correctly receive the first message and I am correctly able to print this.
But now when I hit <code>socket.recv(&amp;message)</code> again the code won't block but will instead throw an exception because the underlying <code>zmq_msg_recv(...)</code> returns a value of -1.</p>

<p>I'm unsure why this is occurring, I cannot see why it is expecting another message as I know that there is nothing else on this port. The only thing I came across is calling <code>zmq_msg_close(...)</code> but this should be called as part of the <code>message_t</code> destructor, which I have confirmed.</p>

<p>Is there anything I'm doing wrong in terms of the socket setup or how I'm using it for the <code>recv(...)</code> call to stop blocking?</p>