* Fix compile error for libzmq 4.2.1 and 4.2.2
When defined ZMQ_BUILD_DRAFT_API=1, you receive an error "'on_event_handshake_succeeded' was not declared in this scope"... which is correct for versions 4.2.1 and 4.2.2.
Function was renamed from 'on_event_handshake_succeed', fixed this by updating the function name.
There are two overloads of `poll` - one that has `-1` as the default value for the timeout, and one that does not have the timeout argument (which calls the previous one with -1 for the timeout). This makes it ambiguous for the compiler when `poll` is called without the timeout.
This patch removes the second overload as it is not needed since the first one already covers the same case.
Line 706 constructor was:
monitor_t() : socketPtr(NULL), monitor_socket{NULL} {}
but should be:
monitor_t() : socketPtr(NULL), monitor_socket(NULL) {}
Note change of bracket types for monitor_socket parameter.
This does not allaw to use monitor_t without a thread.
What is often OK but sometimes not.
Solution:
keep existing interface but add a non blocking alternative.
This can cause monitor_t to crash if used with a socket that was
constructed via the move constructor.
Solution: initialise the context pointer variable ctxptr in the move
constructor.
During introduction of EHOSTUNREACH, missing mapping between
EHOSTUNREACH errno and false/0 return code for socket's send()
calls was missing, throwing an exception.
To be consistent with the rest of wrappers (e.g. DONTWAIT), fix it
by handling this errno as a regular EAGAIN, and let the caller use
errno/zmq_errno() to branch on their code.
This class handles multipart messaging. It is the C++ equivalent of zmsg.h, which is part of CZMQ (the high-level C binding). Furthermore, it is a major improvement compared to zmsg.hpp, which is part of the examples in the ØMQ Guide. Unnecessary copying is avoided by using move semantics to efficiently add/remove parts.
New fill constructor: message_t(const void *data, size_t size). Constructs a new message of the given size and copies the data to the message body. In addition a new rebuild() function that does the same for an already constructed object
When making a debug build with msvc, the range constructor of message_t caused warning 4996: 'std::_Copy_impl': Function call with parameters that may be unsafe. It is actually safe to do what's done in the constructor, so the workaround is to mimic what std::copy does, whitout the range check.
A better/nicer solution to fix the type mismatch warnings (size_t to int). Working with size_t as long as possible and doing the static_cast right before calling the zmq_poll() function of libzmq
Fix the following two problems in message_t's range constructor: (1) The range constructor passed the wrong size for iterator-types larger than one byte, (2) The range constructor didn't compile for const-iterators.
The zmq_msg_recv() function takes the message, socket, and flags while the zmq_recvmsg() function takes the socket, message. This commit addresses that difference.
The zmq_recvmsg() function has been replaced by zmq_msg_recv() since version 3.2.0, and has since been marked as deprecated.
See: https://raw.githubusercontent.com/zeromq/zeromq3-x/master/NEWS
Replace our uses of the old function (which was in monitor_t::monitor()) with the more modern function call. Support backwards compatibility with a #DEFINE macro for versions of zmq preceeding 3.2.0
MSVC complains about conversion of size_t to int. The size_t typedef is
defined as an unsigned __int64 on Win64, which triggers the warning. Two
such instances were fixed with static_cast<int>(size_t)
The issue was discovered by clang:
zmq.hpp:504:34: runtime error: load of misaligned address 0x2b38beb224b2
for type 'int32_t' (aka 'int'), which requires 4 byte alignment
I modified the loads of both event and value to be consistent.
The code added in 'Fixed misaligned structure cast' implicitly assumes zmq 4.x, since it relies on new fields in zmq_event_t structure. This commit re-introduces the previous code if zmq < 4.x is detected.
zmq_event_t is often padded (due to a uint16_t as its first member), and thus you cannot re-interpret bytewise packed message buffers as zmq_event_t, it must be read manually. This was resulting in the value always being garbage, which is troublesome if you wish to inspect a SOCKET, for example.
The only defined error code for zmq_close() is ENOTSOCK
which indicates an error in cppzmq implementation.
It's ok to use assert here instead of throw.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Added a C++11 move constructor and move assignment operator to zmq::socket_t
and zmq::context_t. These functions are only enabled if the compiler supports
C++11 rvalue references. Currently the code can detect rvalue reference
support for the following compilers: GCC, MSVC, clang.
Signed-off-by: Botond Ballo <botond.ballo@gmail.com>
Copyrights and project name adjusted
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>