diff --git a/tests/socket.cpp b/tests/socket.cpp index b4236b23..2ed0eefb 100644 --- a/tests/socket.cpp +++ b/tests/socket.cpp @@ -198,6 +198,25 @@ TEST_CASE("socket send recv message_t", "[socket]") CHECK(rmsg.size() == *res); } +TEST_CASE("socket send recv message_t by pointer", "[socket]") +{ + zmq::context_t context; + zmq::socket_t s(context, zmq::socket_type::pair); + zmq::socket_t s2(context, zmq::socket_type::pair); + s2.bind("inproc://test"); + s.connect("inproc://test"); + + zmq::message_t smsg(size_t{10}); + const auto res_send = s2.send(smsg, zmq::send_flags::none); + CHECK(res_send); + CHECK(*res_send == 10); + CHECK(smsg.size() == 0); + + zmq::message_t rmsg; + const bool res = s.recv(&rmsg); + CHECK(res); +} + TEST_CASE("socket recv dontwait", "[socket]") { zmq::context_t context; diff --git a/zmq.hpp b/zmq.hpp index e336b1b1..12accd95 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -1264,11 +1264,7 @@ class socket_base #ifdef ZMQ_CPP11 ZMQ_DEPRECATED("from 4.3.1, use recv taking a reference to message_t and recv_flags") #endif - bool recv(message_t *msg_, int flags_ -#ifndef ZMQ_CPP11 - = 0 -#endif - ) + bool recv(message_t *msg_, int flags_ = 0) { int nbytes = zmq_msg_recv(msg_->handle(), _handle, flags_); if (nbytes >= 0)