Skip to content

Commit 9c1da76

Browse files
Use send_flags and recv_flags instead of int in multipart_t
1 parent d46df2b commit 9c1da76

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

zmq_addon.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -451,46 +451,46 @@ class multipart_t
451451
bool empty() const { return m_parts.empty(); }
452452

453453
// Receive multipart message from socket
454-
bool recv(socket_ref socket, int flags = 0)
454+
bool recv(socket_ref socket, recv_flags flags = recv_flags::none)
455455
{
456456
clear();
457457
bool more = true;
458458
while (more) {
459459
message_t message;
460-
#ifdef ZMQ_CPP11
461-
if (!socket.recv(message, static_cast<recv_flags>(flags)))
462-
return false;
463-
#else
464460
if (!socket.recv(&message, flags))
465461
return false;
466-
#endif
467462
more = message.more();
468463
add(std::move(message));
469464
}
470465
return true;
471466
}
472467

468+
// Receive multipart message from socket (old)
469+
bool recv(socket_ref socket, int flags = 0) {
470+
return recv(socket, static_cast<recv_flags>(flags));
471+
}
472+
473473
// Send multipart message to socket
474-
bool send(socket_ref socket, int flags = 0)
474+
bool send(socket_ref socket, send_flags flags = send_flags::none)
475475
{
476476
flags &= ~(ZMQ_SNDMORE);
477477
bool more = size() > 0;
478478
while (more) {
479479
message_t message = pop();
480480
more = size() > 0;
481-
#ifdef ZMQ_CPP11
482-
if (!socket.send(message, static_cast<send_flags>(
483-
(more ? ZMQ_SNDMORE : 0) | flags)))
484-
return false;
485-
#else
486481
if (!socket.send(message, (more ? ZMQ_SNDMORE : 0) | flags))
487482
return false;
488-
#endif
489483
}
490484
clear();
491485
return true;
492486
}
493487

488+
// Send multipart message to socket (old)
489+
bool send(socket_ref socket, int flags = 0)
490+
{
491+
return send(socket, static_cast<send_flags>(flags));
492+
}
493+
494494
// Concatenate other multipart to front
495495
void prepend(multipart_t &&other)
496496
{

0 commit comments

Comments
 (0)