Commit Graph

116 Commits

Author SHA1 Message Date
Simon Giesecke
4367bd6128 Problem: code duplication in equals/operator==
Solution: implemented equals using operator==
2018-04-13 11:21:05 -04:00
Pawel Kurdybacha
6caa5d19d3 Problem: message_t should be easier to construct
* Added overload constructor (c++11 only) taking iteratable object.
  It would be easier to use std::string, std::array etc to construct
  a message now. Making it a draft for now in case it is too greedy
  and needs to be more specialize.
* Added equal and not euqal operator to message_t as a recommended
  and expected way of comparing objects in C++.
* deprecated C style equal method as operator== should be used instead
  (point above).
* Added message_t test covering all available message_t's constructors
2018-04-14 12:13:44 +01:00
Pawel Kurdybacha
8353e8460f Problem: non consistent whitespace formatting
* Converted tabs to to 4 spaces to be consistend with the rest of the
code
* Stripped white spaces from the end of lines
2018-04-13 17:35:41 +01:00
Simon Giesecke
5b1ab44264 Problem: insufficient tests for poller_t, bad usability since caller of add must store function object
Solution: added tests, added size() method, added add deprecated overload with former signature, changed new add signature to accept handler by value
2018-04-13 16:24:46 +02:00
Pawel Kurdybacha
1975818171 Problem: poller's handler not aware of event type. (#200)
* Problem: Poller's handler not aware of event type.

It was possible to register a handler for more than one event types but
impossible to distinguish which event is being handled.
Now events are passed to a handler.

Besides that some other changes:
* new test covering changes in the poller
* modified existing tests to cover changes in the poller
* defined handler_t in poller_t scope for more convinient use
  and simpler code
* helper loopback binder to be re-used in tests

* Problem: CMake build fails on Windows

Issue #199

It seems that with GCC on Linux <array> is implicitly included
by one of stl includes already in zmq.hpp but it breaks on Windows
with Visual Studio.

Adding explicit include for array.

Can not verify right now but this change is a good practice
so creating a pull request.

* Poller: array include not between C++11 guards
2018-04-09 08:22:31 +01:00
Pawel Kurdybacha
18f8035ba8 Problem: poller_t does not have great test coverage
@sigiesec's recent commits with gtests and basics tests for zmq
types (thanks for that!) makes it too convinient to not add some more tests.

* Adding some simple tests for poller_t
* Stripped whitespaces from poller implementation.
2018-04-07 23:00:10 +01:00
Simon Giesecke
7a8cc9d7cf Problem: version detection broken, confuses libzmq and cppzmq versions
Solution: Fix version detection and cmake syntax errors
Fixes #182
2018-03-28 12:58:12 +02:00
sigiesec
608613217e Problem: inconsistent error handling in poller_t
Solution: make poller_t::add and poller_t::remove throw error_t on error, return void
2018-03-26 16:59:47 +02:00
sigiesec
16a76513e3 Problem: poller_t is copyable, but does not implement copying properly
Solution: make poller_t non-copyable, but properly movable
2018-03-26 16:58:13 +02:00
Giuseppe Corbelli
0d1c20e2ea Consistently indented some preprocessor directives.
Added a str() method and companion operator<<(std::ostream) similar to multipart_t.
Added some comments to mark the end of preprocessor instructions / class def / namespace def.
2018-03-07 14:14:09 +01:00
Wilbert van de Ridder
59f7d1ca2f Added wrapper for context options 2018-01-27 19:14:35 +01:00
NAIVEddd
d28e13115d
Reduce the duplication. 2017-11-03 13:12:52 +08:00
Simon Giesecke
e325495a39 Problem: implicit type conversion warning
Solution: Added explicit static_cast
2017-10-25 10:13:07 +02:00
Simon Giesecke
af9a92e6a8 Revert "Revert "Fix compile error for libzmq 4.2.1 and 4.2.2"" 2017-10-10 13:42:50 +02:00
Simon Giesecke
8ec71c146a Revert "Fix compile error for libzmq 4.2.1 and 4.2.2 (#161)"
This reverts commit a1000a0dd6.
2017-10-09 16:10:44 +02:00
Frank van Kesteren
a1000a0dd6 Fix compile error for libzmq 4.2.1 and 4.2.2 (#161)
* 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.
2017-10-09 15:02:00 +01:00
Simon Giesecke
4a08086815 Problem: inconsistent symbol naming for ZMQ_VERSION>=4.2.3
Solution: use new on_event_* methods
2017-10-09 14:16:40 +02:00
Ivan Čukić
e93e9f9715 Removing ambiguous overload of poll
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.
2017-09-24 11:24:29 +02:00
sigiesec
0cb94dc32d Problem: inconsistency DRAFT APIs in libzmq 4.2.x
Solution: distinguish cases for libzmq 4.2.0, 4.2.1/4.2.2 and 4.2.3
2017-09-20 12:15:14 +02:00
Lingpho
af523fad7d Fix #147 issuse (#150)
* add more DRAFT API, fix the #147 issue
2017-08-31 20:30:43 +01:00
Simon Giesecke
a94e648495 Revert "Fix rvalue for socket::send() on EHOSTUNREACH" 2017-08-29 11:15:03 +02:00
Luca Boccassi
d9f0f016c0 Problem: copyright years out of date
Solution: update them
List the ZeroMQ community as a shorthand for the full list of authors
as it can be found via git log
2017-07-31 14:30:55 +01:00
juseless
449a0141fb Update zmq.hpp
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.
2017-07-16 20:01:08 -04:00
a4z
d4da63fed6 Problem: monitor_t::monitor function is blocking
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.
2017-07-14 16:03:04 +02:00
a4z
d88414e435 Problem: uninitialized context pointer in socket_t move constructor
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.
2017-07-03 10:35:19 +02:00
Marc Sune
5363388fc5 Fix rvalue for socket::send() on EHOSTUNREACH
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.
2017-06-07 12:09:02 +02:00
bjovke
46fc0572c5 Code formatting, sorry... 2017-04-09 22:16:35 +02:00
bjovke
d9a0fde681 Allow for empty handler parameter (empty std::function()) in call to zmq::poller_t::add(). 2017-04-09 21:34:16 +02:00
John Gornowich
2def369043 update directive for ZMQ_MAKE_VERSION check against zmq_msg_gets method 2017-02-20 08:04:02 -05:00
Pawel Kurdybacha
bafbf2889d poller_t class based on new libzmq poller API 2017-01-31 21:57:51 +00:00
Vincent Tellier
c128d816d9 Added new monitor event since #2227
These are wrapped in DRAFT section.
2017-01-02 06:58:56 +01:00
laplaceyang
eff9bcb6e8 misuse of zmq_send_const 2016-12-15 20:48:24 +08:00
Rider Woo
3431f6882a fix build error with libzmq-3.2.5 (#103)
error zmq_send_const undefined and zmq_msg_gets undefined
2016-12-12 10:30:09 +01:00
Johan Mabille
54414b9d08 fixed warnings in c++11 poll functions 2016-12-09 14:00:44 +01:00
laplaceyang
404b97212b reduce copy 2016-12-08 20:58:38 +08:00
Mateusz Piotrowski
1c8da7cd8d Fix message_t::gets.
- Add a missing underscore.
 - Remove const as msg is passed by reference.
2016-11-15 23:43:15 +01:00
Mateusz Piotrowski
570ff93ea9 Create a binding for zmq_msg_gets.
Additionally, I've changed some tabs to spaces and remove trailing
spaces.
2016-11-15 22:07:00 +01:00
Philip Top
95ce4f2bc2 Update zmq.hpp
add const to what function of error_t
2016-11-06 07:38:16 -08:00
Philip Top
a3f166e5cd added conditional C++11 definitions to match visual studio 2015 2016-10-22 06:24:35 -07:00
Serge Medvedev
8214a500d9 Assertion in dtor of context_t doesn't fail if close method has already been called 2016-09-19 10:27:52 +03:00
Yorick de Wid
bd288a55c1 Remove explicit cast on void pointer operator 2016-07-18 16:51:24 +02:00
Harald Nøkland
e7c2093581 Class for multipart messaging
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.
2016-04-06 14:20:10 +02:00
raulcf
014628cb34 Updating zmq_ctx_shutdown to zmq_ctx_ctx which is imported in zmq.h 2016-01-19 17:39:26 -05:00
Harald Nøkland
fdd9d2d5f0 New fill constructor for message_t
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
2015-12-03 08:43:24 +01:00
Harald Nøkland
18b5870caa Fix warning 4996 in msvc debug build
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.
2015-12-03 08:23:39 +01:00
Harald Nøkland
308239d758 Correction to pull request #56
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
2015-11-30 16:55:51 +01:00
Harald Nøkland
4815c80aed Fix two issues in message_t's range constructor
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.
2015-11-30 15:36:42 +01:00
gdfast
c1e8ac0f19 Make getsockopt() functions const
Make the socket_t::getsockopt() functions (which wrap zmq_getsockopt() ) const because they should only access and not modify socket state.
2015-11-19 12:37:07 -05:00
dquam
baeaebc1cf Fix usage of zmq_msg_recv and zmq_recvmsg
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.
2015-11-12 15:35:16 -06:00
Constantin Rack
7c3d374ff8 Merge pull request #57 from gdfast/patch-1
Avoid using deprecated function zmq_recvmsg
2015-11-10 21:20:22 +01:00