[zeromq-dev] Access ZeroMQ Error Messages in C++?
Papp Áron
aphex999 at gmail.com
Sat Aug 10 16:58:37 CEST 2013
Hi Riskybiz,
you may try using zmq_errno() and zmq_strerror() functions, like this:
*int rc = zmq_connect(server_socket, address);*
*
*
*std::cout << "zmq_connect() rc: " << rc << "\n";*
*std::cout << "errno: " << zmq_strerror(zmq_errno()) << " (" << zmq_errno()
<< ")\n";*
Best,
Aron
2013/7/30 <Richard_Newton at waters.com>
> Hi Riskybiz
>
> Assuming you are using cppzmq it will throw an exception, so you can do:
>
> try
>
> {
> client.connect("tcp://localhost:5555");
> }
> catch (const zmq::error_t& e)
> {
> std::string errStr = e.what();
> }
>
> Ric.
>
>
> [image: Inactive hide details for Riskybiz ---28/07/2013 07:01:58 PM---So
> I've worked out how to get ZeroMQ error messages like so:]Riskybiz
> ---28/07/2013 07:01:58 PM---So I've worked out how to get ZeroMQ error
> messages like so:
>
> From: Riskybiz <riskybizLive at live.com>
> To: zeromq-dev at lists.zeromq.org
> Date: 28/07/2013 07:01 PM
> Subject: [zeromq-dev] Access ZeroMQ Error Messages in C++?
> Sent by: zeromq-dev-bounces at lists.zeromq.org
> ------------------------------
>
>
>
> So I’ve worked out how to get ZeroMQ error messages like so:
>
> int rc = zmq_bind(server, "tcp://*:5555");
>
>
> if(rc == -1)
>
> {
>
> std::string errStr = zmq_strerror(zmq_errno());
>
> std::string errConc = "TestDataAccess: ZMQServer: Bind To REP Failed:
> " + errStr;
>
> const char* errOut = errConc.c_str();
>
> OutputDebugStringA(errOut);
>
> return 1;
>
> }
>
>
>
> Question is; how do I catch ZeroMQ error messages in C++; say if I wanted
> to use:
>
> client.connect("tcp://localhost:5555");
>
> the obvious way I tried:
>
> int rc = client.connect("tcp://localhost:5555");
>
> is just not valid because;
>
> client.connect("tcp://localhost:5555");
>
> returns type ‘void’.
>
> Can anyone provide a quick C++ example of how to accomplish this?
>
> Thanks,
>
> Riskybiz.
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
> ===========================================================
> The information in this email is confidential, and is intended solely for the addressee(s).
> Access to this email by anyone else is unauthorized and therefore prohibited. If you are
> not the intended recipient you are notified that disclosing, copying, distributing or taking
> any action in reliance on the contents of this information is strictly prohibited and may be unlawful.
> ===========================================================
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130810/b34fef73/attachment.htm>
More information about the zeromq-dev
mailing list