Commit Graph

270 Commits

Author SHA1 Message Date
Gudmundur Adalsteinsson
3d4be814e8 Problem: send/recv functions lack type-safety
Solution: Add functions taking buffers and enum class flags
2019-05-05 22:05:47 +00:00
Simon Giesecke
35ba5bea3b
Merge pull request #312 from gummif/gfa/socket-ref
Problem: No type-safe alternatives when polling or needing a reference to a socket
2019-05-02 14:19:40 +02:00
Pierre-Jean Texier
82f6e93dd1 Use C++ cast instead of old style cast
This to avoid the following warning with the '-Wold-style-cast' flag enabled :

./zmq.hpp:763:29: warning: use of old-style cast [-Wold-style-cast]
             return (size_t) nbytes;
                             ^
./zmq.hpp: In member function ‘size_t zmq::socket_t::recv(void*, size_t, int)’:
./zmq.hpp:793:29: warning: use of old-style cast [-Wold-style-cast]
             return (size_t) nbytes;
2019-04-23 23:08:24 +02:00
Gudmundur Adalsteinsson
c6a3529cd1 Problem: No type-safe alternatives when polling or needing a reference to a socket
Solution: Introduce a socket_ref that is a non-owning nullable reference to a socket
2019-04-19 22:10:26 +00:00
Simon Giesecke
f65ddd7597
Merge pull request #314 from gummif/gfa/msg-iter
Problem: Performance of message_t construction can be improved
2019-04-15 11:02:27 +02:00
Simon Giesecke
961bb4fb46
Merge pull request #313 from gummif/gfa/socket-ctor
Problem: socket_t can not be default constructed
2019-04-15 10:58:45 +02:00
Gudmundur Adalsteinsson
cff3a46b73 Problem: Performance of message_t construction can be improved
Solution: Use std::copy instead of a raw loop and fix a conversion
warning
2019-04-14 12:40:01 +00:00
Gudmundur Adalsteinsson
4ceabb37b6 Problem: socket_t can not be default constructed
Solution: Provide a default constructor
2019-04-14 12:21:30 +00:00
Simon Giesecke
132f7b00df
Merge pull request #309 from gummif/gfa/poller-millis
Problem: zmq_poller_wait_all is called with microseconds count
2019-04-07 21:15:59 +02:00
Gudmundur Adalsteinsson
ed63f9adae Problem: zmq_poller_wait_all is called with microseconds count
Solution: Change wait_all parameter type to std::chrono::milliseconds
2019-04-07 10:56:27 +00:00
Gudmundur Adalsteinsson
16f16eeaad Problem: message_t lacks empty() function
Solution: Add function and qualify with nodiscard like std types
2019-04-04 17:55:27 +00:00
Simon Giesecke
5c95a07d72
Merge pull request #306 from gummif/gfa/detect-std
Problem: Missing detection of standards greater than C++11
2019-04-04 16:56:16 +02:00
Simon Giesecke
d1e7c538cc
Merge pull request #303 from gummif/gfa/swap
Problem: Missing swap functions
2019-04-04 14:51:10 +02:00
Simon Giesecke
5c69a36b95
Merge pull request #304 from gummif/gfa/monitor-move
Problem: monitor_t incorrectly deletes socket_t move assignment operator
2019-04-04 09:15:55 +02:00
Gudmundur Adalsteinsson
77575ce705 Problem: Missing detection of standards greater than C++11
Solution: Add macros detecting C++14 and C++17
2019-04-03 17:03:39 +00:00
Gudmundur Adalsteinsson
b6a07be512 Problem: monitor_t incorrectly deletes socket_t move assignment operator
Solution: Implement a move assignment operator for monitor_t
2019-04-03 14:04:58 +00:00
Gudmundur Adalsteinsson
72f0e1bcba Problem: message_t move and copy are mutating but take const
Solution: Deprecate old functions and add overloads taking non-const
references
2019-04-03 13:56:11 +00:00
Gudmundur Adalsteinsson
83b91c8b7e Problem: Missing swap functions
Solution: Implement for socket_t, context_t, message_t and poller_t
Additionally remove dependency on <functional> by refactoring poller_t
and remove unused <unordered_map> include.
2019-04-03 13:23:17 +00:00
Simon Giesecke
e1fe5e5209
Merge pull request #301 from gummif/gfa/proxy
Problem: proxy is not typesafe
2019-04-01 08:28:54 +02:00
Gudmundur Adalsteinsson
3fecadfb86 Problem: Redundant inline specifiers for member functions
Solution: Remove specifiers, since they are implicitly inline
2019-03-31 22:39:58 +00:00
Gudmundur Adalsteinsson
1eedfaf9a5 Problem: proxy is not typesafe
Solution: Add overloads to proxy and proxy_steerable taking socket_t
objects
2019-03-31 22:30:10 +00:00
Simon Giesecke
9e03629dae
Merge pull request #298 from gummif/gfa/poll-const
Problem: poll is mutating by definition
2019-03-28 09:25:19 +01:00
Gudmundur Adalsteinsson
0e55254bd6 Problem: poll is mutating by definition
Solution: Remove const qualifiers and const_cast
2019-03-27 20:47:36 +00:00
Gudmundur Adalsteinsson
ff23b4ce95 Problem: Friendship between socket_t and context_t
Solution: Not needed since the void* can be obtained from the API of
context_t
2019-03-26 21:58:38 +00:00
Ivan Čukić
7d59f129c8 Removed warnings when compiling with C++11 enabled (#296)
* Removed warnings when compiling with C++11 enabled

* ZMQ_NOTHROW now means throw() for pre-C++11
2019-03-13 19:18:27 +01:00
trya
16fa983281 Add message_t::get()
Uses zmq_msg_get() to get some integer properties on the message.
2019-03-08 16:40:21 +01:00
E. G. Patrick Bos
fbe82b07cd
Add retry of zmq_ctx_destroy in context_t::close()
Fixes #171
2018-11-05 20:09:28 +01:00
Pawel Kurdybacha
ae15964907 Problem: Dependency on googletest framework
Currently cppzmq as relatively simple and header only library depends on rather
complex unit test framework googletest.
Current issues:
- Googletest requires downloading and building it every time on travis
as cache support is limited there
- Googletest build is signifficant with comparison to cppzmq unittests
total runtime

Solution: Port existing tests to Catch - header only C++ framework and
gain ~20% build speed up on travis.

Why Catch?
It is well know C++ header only testing framework. It works well, it is
being kept up to date and maintainers seem to pay attention to
community's comments and issues.
We can not use Catch2 currently as we still support pre-C++11 compilers.
2018-10-17 15:22:07 +01:00
Simon Giesecke
7d53a04e81 Set version to 4.3.1 to prepare bugfix release 2018-08-21 13:51:17 +02:00
Simon Giesecke
ab09f5da98 Problem: addition of new single-argument message_t introduces ambiguity when calling e.g. socket_t::send
Solution: make single-argument constructor explicit
2018-08-21 13:50:02 +02:00
Simon Giesecke
f5963ceade Update version to 4.4.0 for next development iteration 2018-08-15 17:55:43 +02:00
Joseph Artsimovich
751f27d635 Add support for RADIO/DISH sockets if draft API is enabled
This commit introduces new socket_type enumeration values as well
as the following supporting functions:

socket_t::join()
socket_t::leave()
message_t::group()
message_t::set_group()
2018-07-13 16:01:15 +03:00
Ben
a604af95d7 editing "typename I" to "typename T" due to error: expected nested-name-specifier before ‘(’ token
on c++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
2018-06-10 23:54:20 -07:00
Simon Giesecke
58ffef7190 Problem: no tests for monitor_t::abort
Solution: add a test and fix implementation of monitor_t::abort to make it usable
2018-06-05 17:27:32 +02:00
Joseph Artsimovich
d4374cbebe Add message_t::routing_id() and set_routing_id()
Setting a routing id is necessary when sending a message through a
ZMQ_SERVER socket. See [1] for more details.

[1] http://api.zeromq.org/4-2:zmq-socket#toc5
2018-05-19 08:44:41 +03:00
Pawel Kurdybacha
ff3c221516 Problem: whitespace style too restrictive.
For header only library like cppzmq, whitespace style inherited from
libzmq is too restrictive.

Solution: relaxing whitespace before parens from always to in control
statements only, increased max column width from 80 to 85 and removing
requirement of whitespace after template keyword.
2018-05-12 17:28:28 +01:00
Giesecke
65ae6b33fd Problem: poller_t::wait_all and active_poller_t::wait declare int return type but actually return an element count
Solution: change return type to size_t, remove a redundant if in consequence
2018-05-12 09:18:46 +02:00
Pawel Kurdybacha
5031278f18 Problem: project files do not follow clang-format 2018-05-11 20:29:15 +01:00
Simon Giesecke
882f5e844c Problem: extra abstraction layer type poller_t is in zmq.hpp
Solution: move to zmq_addon.hpp, rename to active_poller_t, and rename base_poller_t to poller_t
2018-05-11 11:33:53 +02:00
Simon Giesecke
bf47be0a0c Problem: poller_t adds an abstraction layer on zmq_poller_*
Solution: extract base_poller_t from poller_t, which provides a direct mapping of zmq_poller_* to C++ only
2018-05-11 11:02:27 +02:00
Simon Giesecke
cdef8bc069
Merge pull request #222 from kurdybacha/poller-init
Problem: poller's constructor is not default generated
2018-05-11 08:12:52 +02:00
Pawel Kurdybacha
33025bf0e6 Problem: client/server socket types not defined.
Solution: Add ZMQ_CLIENT and ZMQ_SERVER to socket_type enum.
Update some of draft guarded unit tests to use them.
2018-05-11 06:41:53 +01:00
Pawel Kurdybacha
c03fb35173 Problem: poller's constructor is not default
Solution: Constructor logic moved to the same place where cleanup is and
marking constructor `default`. Init/cleanup code is in one pleace making
it easier to read/maintain.
2018-05-11 05:56:07 +01:00
Pawel Kurdybacha
559d373da3 Add back size method, add empty for completeness
As disscussed on #219 PR bringing back `size` method and adding `empty`
for completeness.
2018-05-09 05:44:11 +01:00
Pawel Kurdybacha
4dde37e7b2 Make poller default movable
Latest modification to the poller made move constructor and move
assigment operator not complete. In order to prevent that in the future
poller should be default movable. Unique pointer has been used to
manager zmq_poller. That makes code simpler and safer now.
2018-05-08 21:56:15 +01:00
Pawel Kurdybacha
faf6671d38 Problem: poller can segfault when modified from registered handler. (#219)
* Problem: poller can segfault when modified from registred handler.

It is possible that a user would like to add/remove sockets from
handlers. As handlers and poll items might be removed while not
being processed yet - we have a segfault situation.
Provided unit test `remove_from_handler` demonstrates the problem.

Solution: Modify internal poll item data structure only after processing
of events is finished.

Please not that events processing path performance remains the same when there are
no modification (add/remove) to the poller (no rebuild) - main real use case.

As an effect of changes `size()` method has been removed as it does not
represent any meaningful information anymore. There are active and pending
(waiting for rebuild) poll items so two different sizes. User can
easily track on their side number of registered sockets if original size
information is needed.

`wait` method returns number of processed sockets now. It might be
useful information to a user for no extra cost.
2018-05-03 21:10:05 +01:00
Pawel Kurdybacha
94e0fb0bc3 Problem: deprecated poller's method in draft API
We have a deprecated method `add` in poller that contradicts purpose of a draft
API where it can change without deprecation period.

Solution: remove the method so we do not to maintain it anymore.
2018-04-26 19:50:14 +01:00
Pawel Kurdybacha
85e05b0c88 Problem: poller_t does not support modify
Solution: Added `modify` method based on `zmq_poller_modify` and test cases
covering it.
Reduced code duplication in existing test cases by introducing
`client_server_setup` helper struct.
2018-04-24 21:16:01 +01:00
Pawel Kurdybacha
c55379d6e2 Problem: poller_t's deprecated add might throw std::bad_function_call
Issue is reproducible in deprecated add method with empty handler
followed by wait that kicks in (covered by provided unit test).

I would prefer we remove this method completely as maintaining something
that we consider `deprecated` is unnecessary in `draft` API.
2018-04-20 06:16:04 +01:00
Pawel Kurdybacha
f5b9fcc4ef Problem: throw error_t should follow only zmq call. 2018-04-18 19:23:26 +01:00
Pawel Kurdybacha
810b87c021 Problem: poller_t invalid behaviour on invalid sockets
On adding invalid socket (e.g. after move) there was exception thrown
but leaving modified and unconsistent internal state.
Besides that there was no possibility to remove a socket that was moved
into.

Solutions: check for socket validity (added operator bool) and changed
internal unordered_map "handlers" to operator on zmq internal pointers.

Added two test cases covering the issues.
2018-04-18 07:00:41 +01:00
Pawel Kurdybacha
fdc145a09e Problem: Windows build broken because of multiple issues (#204)
* Problem: Windows build broken because of multiple issues

Windows issues:
* missing includes files
  Solution: added missing <memory> and <unordered_map>
  Here <map> was replaced with <unordered_map> as there is no need for
  sorted map.
* googletest fails because deprecation warning causing errors.
  Solution: D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING option added.
* googletest fails because by default, new Visual Studio projects
  link the C runtimes dynamically but Google Test links them statically.
  Solution: gtest_force_shared_crt=ON option added.

Besides that adding appveyor.yml configuration to add Windows build to
CI in order to prevent accidental Windows build breakage.
For now only Debug configuration as Release requires more time to figure
out.

* Problem: Windows build takes too long

Solution: disabling tests and perf tools

* Problem: Windows unit_tests executable not finding lizmq dll.

Solution: copy libzmq dll to build bin directory.

* Problem: Windows build fails because wrong test path provided
2018-04-17 09:29:47 +01:00
Simon Giesecke
2aac1dffa3 Problem: bad code style in operator==
Solution: simplified code
2018-04-13 11:38:16 -04:00
Simon Giesecke
c92afb675e Problem: message_t::operator== is absurdly inefficient and constructs temporary copies of both operands
Solution: implement operator== using memcmp instead
2018-04-13 11:28:40 -04:00
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
Constantin Rack
fadb37e4a7 Merge pull request #52 from revaultch/master
Fixes assertion error: src/mutex.hpp:123
2015-11-10 21:20:11 +01:00
gdfast
5989203558 Avoid using deprecated function zmq_recvmsg
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
2015-11-10 15:14:21 -05:00
Christopher D. McMurrough
0feecde95c fixed type mismatch warnings (size_t to int)
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)
2015-11-05 17:21:24 -06:00
Jim Hague
87b12c806a Extend C++11 guard to cover remaining use of std::vector data().
Now compiles without error with a pre-C++11 compiler (g++-3.3).

Fixes #53
Please enter the commit message for your changes. Lines starting
2015-11-01 16:08:56 +00:00
Urs Keller
971092e472 Fixes assertion error, when destroing ctx while creating a socket from a different thread: ./src/mutex.hpp:123 2015-10-02 16:32:36 +02:00
Spyros Ligouras
05a0256d0e Fix backward compatibility 2015-09-26 13:20:37 +03:00
jens
34c8e4395c Fixed some const-correctness issues
C++11-ified some stuff:
overloads with C++11 types, nothrow

Added some template methods to work with messages and sockets
2015-07-05 13:29:03 +02:00
Todd Neal
67b216681d Add an rvalue overload for socket_t::send
This lets you create functions that return message_t's by value, and
pass them to send() with no copy.
2015-03-05 16:06:36 -06:00
Todd Neal
f141cf5bfc Fix a misaligned load
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.
2015-03-05 08:19:13 -06:00
Pieter Hintjens
7f6cc85df8 Problem: zmq_event_t removed in libzmq v4.1
Solution: define this if we need it, so that caller can use it
on all versions of libzmq.

Fixes #40
2014-09-11 08:32:58 +02:00
zbierak
a819813095 Fixes backward compatibility with zmq 3.x
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.
2014-08-08 08:18:16 +00:00
Justin Boswell
0c0f3ae451 Fixed misaligned structure cast
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.
2014-08-06 14:49:59 -04:00
Cosmo Harrigan
04d2897605 Fix for #34
As of right now, the steerable proxy functionality requires version 4.1.0.
2014-03-20 22:35:50 -07:00
Cosmo Harrigan
9683327efc Add proxy_steerable interface for zmq_proxy_steerable in versions >= 4.0.4 2014-03-17 18:20:51 -07:00
evgeny
2658780e3a Fixed assert on Win8.1. Thanks to jonwfreeman. 2014-03-14 13:06:11 +04:00
evgeny
1b7948c6d9 Added parameter to set the max number of sockets. 2014-03-03 19:21:18 +04:00
Jonny Dee
6c17af22b7 monitor_t: Avoid compiler warnings resulting from unused method parameters. 2013-07-18 23:52:44 +02:00
Markus Rothe
830d2ede86 Revert "Fix missing include".
Don't include <string> twice. Another include was introduced in 938e4ab0.

This reverts commit f1fd8f8f6a.
2013-07-17 13:59:06 +02:00
Andrey Sibiryov
f43e83e34e Merge pull request #22 from ricnewton/monitor_updates
Move monitoring functionality out of socket_t and into monitor_t
2013-07-16 06:10:47 -07:00
Andrey Sibiryov
7975875acd Merge pull request #23 from cjuniet/master
Fix missing include
2013-07-16 04:18:56 -07:00
Colin Steifel
6a04e4a7f3 Changed context_t to use new zmq_ctx_* functions 2013-07-13 14:52:51 -04:00
Colin Steifel
b9d239b0db Adding space between function and args to conform with style 2013-07-12 17:59:42 -04:00
Colin Steifel
9751701d7a Changed from static_cast to != to avoid warnings 2013-07-12 17:36:23 -04:00
Colin Steifel
b6839cd50d Adding ability to check for multipart messages 2013-07-12 17:02:10 -04:00
Christophe Juniet
f1fd8f8f6a Fix missing include
Add a missing include for std::string.
2013-07-04 18:46:52 +02:00
Richard Newton
32546c6538 Convert all tabs to spaces to match formatting style for rest of the file. 2013-07-01 13:33:28 +01:00
Richard Newton
666cc7ae4e Implement monitor aborting. This relies on having the new ZMQ_EVENT_MONITOR_STOPPED event. 2013-07-01 13:31:33 +01:00
Richard Newton
37d5ecd7e2 Add event called after we have connected up our paired socket, we are guaranteed to get monitor events after this point.
This is useful if you are spawning the monitor to a different thread and need to wait until monitor has started before opening the socket.
2013-06-28 18:31:00 +01:00
Richard Newton
938e4ab07b Rework monitor to support both new (3.3 and above) and old ways montior events work. 2013-06-28 17:32:49 +01:00
Richard Newton
dfea887ecb Parse event structure as data for event handlers. 2013-06-28 14:07:27 +01:00
Richard Newton
61a21bb082 Avoid a memcpy in monitor_t 2013-06-28 12:34:18 +01:00
Richard Newton
b34444d273 Rework monitor_t. 2013-06-28 12:22:21 +01:00
Pieter Hintjens
c36e3065d2 Merge pull request #18 from Kobolog/master
Prevent -Wunused-value warnings from non-debug ZMQ_ASSERT macro
2013-06-27 10:55:54 -07:00
Pieter Hintjens
b009df6499 Merge pull request #17 from grefab/master
Allowing for unbind and disconnect
2013-06-27 10:55:43 -07:00
Pieter Hintjens
d5cf3c9410 Merge pull request #15 from montoyaedu/master
Added monitor_t class
2013-06-27 10:55:23 -07:00
Emmanuel Taurel
3afc98efa1 Add a disconnect method (interface to the zmq_disconnect call) in the socket_t class 2013-06-26 17:04:45 +02:00
Andrey Sibiryov
2fe20236f5 prevent unused expression result warnings from non-debug ZMQ_ASSERT macro expansion 2013-04-06 04:14:30 +04:00
Gregor Fabritius
2798087c2e added possibility to disconnect. 2013-02-23 22:01:31 +01:00
Gregor Fabritius
de8059f190 added possibility to unbind. 2013-02-23 19:50:59 +01:00
Ian Barber
b232978003 Merge pull request #14 from robertmaynard/master
Define ZMQ_DELETED_FUNCTION on older clang versions.
2013-02-13 11:59:36 -08:00
H. Eduardo Montoya Sánchez
f30f92b392 syntax & bug fixing
modified monitor_t interface
2013-01-30 17:30:05 +01:00
H. Eduardo Montoya Sánchez
bcdf163fa8 work in progress... 2013-01-30 15:22:54 +01:00
Montoya Edu
9f7a5f18d1 Update zmq.hpp
corrected monitor_t::on_event_unknown prototype
corrected indentation
2013-01-29 19:14:17 +01:00
Montoya Edu
b1dacd8d0f Update zmq.hpp
work in progress...
added monitor_t class
added monitor() method
2013-01-29 19:11:33 +01:00
Robert Maynard
a5174232d5 Correctly define ZMQ_DELETED_FUNCTION when using older clang compilers.
If you are using a version of clang that doesn't support cxx_deleted_functions
we need to define ZMQ_DELETED_FUNCTION to be empty.
2013-01-09 10:19:11 -05:00
John Swinbank
cc25ef9c52 Interface to zmq_proxy() 2013-01-05 15:50:28 +01:00