17#ifndef ZMQPP_SOCKET_HPP_
18#define ZMQPP_SOCKET_HPP_
43#if (ZMQ_VERSION_MAJOR >= 4)
57 const int all = ZMQ_EVENT_ALL;
80#if (ZMQ_VERSION_MAJOR == 2)
81 dont_wait = ZMQ_NOBLOCK,
83 dont_wait = ZMQ_DONTWAIT,
85 send_more = ZMQ_SNDMORE,
86#ifdef ZMQ_EXPERIMENTAL_LABELS
87 send_label = ZMQ_SNDLABEL
119#if (ZMQ_VERSION_MAJOR > 3) || ((ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR >= 2))
153 template<
typename InputIterator>
154 void connect(InputIterator
const& connections_begin, InputIterator
const& connections_end)
156 for(InputIterator it = connections_begin; it != connections_end; ++it)
168#if (ZMQ_VERSION_MAJOR > 3) || ((ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR >= 2))
179 template<
typename InputIterator>
180 void disconnect(InputIterator
const& disconnections_begin, InputIterator
const& disconnections_end)
182 for(InputIterator it = disconnections_begin; it != disconnections_end; ++it)
235 bool send(std::string
const&
string,
bool const dont_block =
false);
249 bool receive(std::string&
string,
bool const dont_block =
false);
263 bool send(
signal sig,
bool dont_block =
false);
277 bool receive(
signal &sig,
bool dont_block =
false);
292 bool send(
std::
string const&
string,
int const flags);
307 bool receive(
std::
string&
string,
int const flags);
322 bool send_raw(
char const* buffer,
size_t const length,
int const flags = normal);
341 bool receive_raw(
char* buffer,
size_t& length,
int const flags = normal);
356 void subscribe(
std::
string const& topic);
376 template<typename InputIterator>
377 void subscribe(InputIterator const& topics_begin, InputIterator const& topics_end)
379 for(InputIterator it = topics_begin; it != topics_end; ++it)
397 void unsubscribe(std::string
const& topic);
417 template<
typename InputIterator>
418 void unsubscribe(InputIterator
const& topics_begin, InputIterator
const& topics_end)
420 for(InputIterator it = topics_begin; it != topics_end; ++it)
433 bool has_more_parts()
const;
441 void set(socket_option
const option,
int const value);
451 void set(socket_option
const option,
bool const value);
459 void set(socket_option
const option, uint64_t
const value);
467 void set(socket_option
const option, int64_t
const value);
476 void set(socket_option
const option,
char const* value,
size_t const length);
484 inline void set(socket_option
const option,
char const* value) {
set(option, value, strlen(value)); }
492 inline void set(socket_option
const option, std::string
const value) {
set(option, value.c_str(), value.length()); }
500 void get(socket_option
const option,
int& value)
const;
508 void get(socket_option
const option,
bool& value)
const;
516 void get(socket_option
const option, uint64_t& value)
const;
524 void get(socket_option
const option, int64_t& value)
const;
532 void get(socket_option
const option, std::string& value)
const;
541 template<
typename Type>
542 Type
get(socket_option
const option)
const
549#if (ZMQ_VERSION_MAJOR >= 4)
558 void monitor(
endpoint_t const monitor_endpoint,
int events_required);
610 operator bool()
const;
617 operator void*()
const;
628 void track_message(
message_t const&, uint32_t
const,
bool&);
The context class represents internal zmq context and io threads.
Definition: context.hpp:47
a zmq message with optional multipart support
Definition: message.hpp:44
The socket class represents the zmq sockets.
Definition: socket.hpp:76
void unsubscribe(InputIterator const &topics_begin, InputIterator const &topics_end)
Unsubscribe from a topic.
Definition: socket.hpp:418
socket & operator=(socket const &) NOEXCEPT ZMQPP_EXPLICITLY_DELETED
socket(socket const &) NOEXCEPT ZMQPP_EXPLICITLY_DELETED
zmq_msg_t _recv_buffer
Definition: socket.hpp:622
void set(socket_option const option, std::string const value)
Set the value of an option in the underlaying zmq socket.
Definition: socket.hpp:492
socket_type type() const
Get the type of the socket, this works on zmqpp types and not the zmq internal types.
Definition: socket.hpp:110
socket_type _type
Definition: socket.hpp:621
void connect(InputIterator const &connections_begin, InputIterator const &connections_end)
Asynchronously connects to multiple endpoints.
Definition: socket.hpp:154
void disconnect(InputIterator const &disconnections_begin, InputIterator const &disconnections_end)
Disconnects from multiple previously connected endpoints.
Definition: socket.hpp:180
Type get(socket_option const option) const
For those that don't want to get into a referenced value this templated method will return the value ...
Definition: socket.hpp:542
void * _socket
Definition: socket.hpp:620
void set(socket_option const option, char const *value)
Set the value of an option in the underlaying zmq socket.
Definition: socket.hpp:484
#define NOEXCEPT
Definition: compatibility.hpp:122
#define ZMQPP_DEPRECATED(reason)
Definition: compatibility.hpp:118
#define ZMQPP_EXPORT
Definition: compatibility.hpp:39
#define ZMQPP_EXPLICITLY_DELETED
Definition: compatibility.hpp:107
const int accept_failed
Definition: socket.hpp:52
const int monitor_stopped
Definition: socket.hpp:56
const int connect_delayed
Definition: socket.hpp:47
const int listening
Definition: socket.hpp:49
const int connected
Definition: socket.hpp:46
const int close_failed
Definition: socket.hpp:54
const int connect_retried
Definition: socket.hpp:48
const int all
Definition: socket.hpp:57
const int closed
Definition: socket.hpp:53
const int bind_failed
Definition: socket.hpp:50
const int accepted
Definition: socket.hpp:51
const int disconnected
Definition: socket.hpp:55
C++ wrapper around zmq.
Definition: actor.cpp:30
message message_t
message type
Definition: socket.hpp:41
std::string endpoint_t
endpoint type
Definition: socket.hpp:39
signal
Signal is a 8 bytes integer.
Definition: signal.hpp:25
ZMQPP_COMPARABLE_ENUM socket_type
Socket types allowed by zmq.
Definition: socket_types.hpp:30
context context_t
context type
Definition: socket.hpp:40