Open kakyoism opened 5 years ago
First I would try changing the receiving part to something like
std::array<char, 1024> buf{};
auto ret = socket.recv(zmq::buffer(buf), zmq::recv_flags::none);
if (ret)
{
std::cout << "Received request: [" << std::string(buf.data(), ret->size) << "]" << std::endl;
}
else
{
std::cout << "Receive timeout" << std::endl;
continue;
}
And also try changing e.num()
to e.what()
to get an error description. You can also simplify the send with socket.send(zmq::buffer(std::string_view("World")), zmq::send_flags::dontwait);
.
I'm new to zmq and cppzmq. While trying to run the multithreaded example in the official guide: http://zguide.zeromq.org/cpp:mtserver
My setup
I hit a few problems.
Problem 1
When running source code in the guide, it hangs forever without any stdout output shown up.
Here is the code directly copied from the Guide.
It crashes soon after I put a breakpoin in the while loop of the worker.
Problem 2
Noticing that the compiler prompted me to replace deprecated API calls, I modified the above sample code to make the warnings disappear.
This code keeps giving me error number
156384763
from the try-catch block. I can't find the definition of the error number.I'd appreciate it if anyone can point out where I did wrong.