hello

attached to this mail are two minimum programs.
i am using debian linux with libzmq3 version 4.0.5.
compile the programs like this:

gcc -Wall -Werror server.c -o server -lzmq
gcc -Wall -Werror client.c -o client -lzmq

now start them both.

output of server process:
receiving first
sending first
receiving second
*** now blocking forever

output of client process:
sending first
sending second
*** now blocking forever

If i do not set the options ZMQ_REQ_RELAXED and ZMQ_REQ_CORRELATE in
the client process, then sending the second time of course fails
because the state machine is in receive mode. But with this option I
would expect it does not block, but instead send the next message which
should then be received in the server. instead the client blocks
forever which I do not understand. What's wrong here?


Erik
#include <assert.h>
#include <stdio.h>
#include <zmq.h>

int main(int argc, char* argv[])
{
  void *context = zmq_ctx_new();
  assert (context);

  void *socket = zmq_socket (context, ZMQ_REQ);
  assert(socket);

  int option=1;
  assert (zmq_setsockopt(socket, ZMQ_REQ_RELAXED, &option, sizeof(option)) == 0);
  option = 1;
  assert (zmq_setsockopt(socket, ZMQ_REQ_CORRELATE, &option, sizeof(option)) == 0);

  assert(zmq_bind(socket, "tcp://*:5555") == 0);

  printf("sending first\n");
  char buffer;
  assert(zmq_send (socket, &buffer, 1, 0) > 0);

  printf("sending second\n");
  assert(zmq_send (socket, &buffer, 1, 0) > 0);

  printf("done\n");

  return 0;

}
#include <assert.h>
#include <stdio.h>
#include <zmq.h>

int main(int argc, char* argv[])
{
  void *context = zmq_ctx_new();
  assert (context);

  void *socket = zmq_socket (context, ZMQ_REP);
  assert(socket);

  assert(zmq_connect(socket, "tcp://localhost:5555") == 0);

  printf("receiving first\n");
  char buffer;
  assert(zmq_recv (socket, &buffer, 1, 0) > 0);

  printf("sending first\n");
  assert(zmq_send (socket, &buffer, 1, 0) > 0);

  printf("receiving second\n");
  assert(zmq_recv (socket, &buffer, 1, 0) > 0);

  printf("done\n");

  return 0;

}
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to