mercredi 3 avril 2019

ZeroMQ server client start sequence

Facing a issue if the client is started before server

Specs : ubuntu 16.04 with c++11,libzmq : 4.2.3

problem : sample codes

server.cpp

int main()
{
zmq::context_t context(1);
zmq::socket_t requester(context,ZMQ_ROUTER);
.
//code to get address
.    
requester.bind(address);

while(true)
{
zmq::message_t message;
requester.recv(&message);
.
//remaining code
.
}
return 0;
}

client.cpp

int main()
{
zmq::context_t context(1);
zmq::socket_t requester(context,ZMQ_DEALER);
.
//code to get address
.
requester.connect(address);
zmq::message_t message;
.
//populate the message to send
.

requester.send(message);
return 0;
}

I know that in zmq i can start client even if the server is not running,but my client application has to include a safety check which requires the server to be started.Is there any way i can achieve by making connect fail or someother workaround.Timeout options doesnt work for me

Aucun commentaire:

Enregistrer un commentaire