На сервере работает ROUTER, на клиенте DEALER. Сервер:
void *context = zmq_ctx_new ();
mitm_socket = zmq_socket (context, ZMQ_ROUTER);
int rc = zmq_bind (mitm_socket, "tcp://*:5556");
....
int result = zmq_msg_recv (&client,mitm_socket,0);
perror("Client: ");
printf("Errno CLI = %d\n", errno);
if(errno == EAGAIN)
printf("CLI EAGAIN\n");
result = zmq_msg_recv (&garbage,mitm_socket,0);
perror("Garbage: \n");
printf("Errno GARB = %d\n", errno);
if(errno == EAGAIN)
printf("GARB EAGAIN\n");
result = zmq_msg_recv (&msg,mitm_socket ,0);
perror("Data\n");
int ling_period_osmo=1000;
int recv_timeout_osmo=-1;
void *osmo_context = zmq_ctx_new ();
void *osmo_socket = zmq_socket (osmo_context, ZMQ_DEALER);
zmq_setsockopt (osmo_socket, ZMQ_IDENTITY,identity, strlen(identity));
zmq_setsockopt (osmo_socket, ZMQ_LINGER, &ling_period_osmo, sizeof(int));
zmq_setsockopt (osmo_socket, ZMQ_RCVTIMEO, &recv_timeout_osmo, sizeof(int));
if(zmq_connect (osmo_socket, "tcp://localhost:5556") == -1){
printf("Couldn't connect to osmocom\n");
return NULL;
}
....
int osmo_send_result = zmq_send (osmo_socket,ack_object("SMS_RECV_ACK","1"),strlen(ack_object("SMS_RECV_ACK","1")), 0);
printf("We send sms_recv_ack with code 1, res = %d\n",osmo_send_result);
Client: : Resource temporarily unavailable
Errno CLI = 11
CLI EAGAIN
Garbage:
: Resource temporarily unavailable
Errno GARB = 11
GARB EAGAIN