Skip to content

Commit

Permalink
Merge pull request #328 from xiphon/fix-recv-flags-default
Browse files Browse the repository at this point in the history
Fix 'recv' function 'flags_' argument default value
  • Loading branch information
sigiesec authored Jul 24, 2019
2 parents 4e37816 + 19b5222 commit 86876d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 19 additions & 0 deletions tests/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 86876d7

Please sign in to comment.