17 #ifndef ZMQPP_SOCKET_HPP_
18 #define ZMQPP_SOCKET_HPP_
43 #if (ZMQ_VERSION_MAJOR >= 4)
57 const int all = ZMQ_EVENT_ALL;
79 #if (ZMQ_VERSION_MAJOR == 2)
85 #ifdef ZMQ_EXPERIMENTAL_LABELS
86 static const int send_label;
115 void bind(endpoint_t
const& endpoint);
117 #if (ZMQ_VERSION_MAJOR > 3) || ((ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR >= 2))
123 void unbind(endpoint_t
const& endpoint);
136 void connect(endpoint_t
const& endpoint);
151 template<
typename InputIterator>
152 void connect(InputIterator
const& connections_begin, InputIterator
const& connections_end)
154 for(InputIterator it = connections_begin; it != connections_end; ++it)
166 #if (ZMQ_VERSION_MAJOR > 3) || ((ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR >= 2))
177 template<
typename InputIterator>
178 void disconnect(InputIterator
const& disconnections_begin, InputIterator
const& disconnections_end)
180 for(InputIterator it = disconnections_begin; it != disconnections_end; ++it)
203 bool send(message_t&
message,
bool const dont_block =
false);
227 bool send(std::string
const&
string,
int const flags = normal);
239 bool receive(std::string&
string,
int const flags = normal);
251 bool send(
signal sig,
bool dont_block =
false);
277 bool send_raw(
char const* buffer,
size_t const length,
int const flags = normal);
294 bool receive_raw(
char* buffer,
size_t& length,
int const flags = normal);
309 void subscribe(std::string
const& topic);
329 template<
typename InputIterator>
330 void subscribe(InputIterator
const& topics_begin, InputIterator
const& topics_end)
332 for(InputIterator it = topics_begin; it != topics_end; ++it)
370 template<
typename InputIterator>
371 void unsubscribe(InputIterator
const& topics_begin, InputIterator
const& topics_end)
373 for(InputIterator it = topics_begin; it != topics_end; ++it)
429 void set(
socket_option const option,
char const* value,
size_t const length);
445 inline void set(
socket_option const option, std::string
const value) {
set(option, value.c_str(), value.length()); }
485 void get(
socket_option const option, std::string& value)
const;
494 template<
typename Type>
502 #if (ZMQ_VERSION_MAJOR >= 4)
511 void monitor(endpoint_t
const monitor_endpoint,
int events_required);
557 operator
bool() const;
564 operator
void*() const;
573 socket& operator=(
socket const&) NOEXCEPT ZMQPP_EXPLICITLY_DELETED;
const int connected
Definition: socket.hpp:46
~socket()
This will close any socket still open before returning.
Definition: socket.cpp:56
bool has_more_parts() const
If the last receive part call to the socket resulted in a label or a non-terminating part of a multip...
Definition: socket.cpp:369
context context_t
context type
Definition: socket.hpp:40
void close()
Closes the internal zmq socket and marks this instance as invalid.
Definition: socket.cpp:118
socket_type type() const
Get the type of the socket, this works on zmqpp types and not the zmq internal types.
Definition: socket.hpp:108
static const int dont_wait
Definition: socket.hpp:82
const int all
Definition: socket.hpp:57
signal wait()
Wait on signal, this is useful to coordinate thread.
Definition: socket.cpp:846
void disconnect(endpoint_t const &endpoint)
Disconnects a previously connected endpoint.
Definition: socket.cpp:107
#define ZMQPP_EXPLICITLY_DELETED
Definition: compatibility.hpp:100
void * _socket
Definition: socket.hpp:567
C++ wrapper around zmq.
Definition: actor.cpp:29
void unsubscribe(InputIterator const &topics_begin, InputIterator const &topics_end)
Unsubscribe from a topic.
Definition: socket.hpp:371
static const int normal
Definition: socket.hpp:78
zmq_msg_t _recv_buffer
Definition: socket.hpp:569
The socket class represents the zmq sockets.
Definition: socket.hpp:75
void connect(InputIterator const &connections_begin, InputIterator const &connections_end)
Asynchronously connects to multiple endpoints.
Definition: socket.hpp:152
void monitor(endpoint_t const monitor_endpoint, int events_required)
Attach a monitor to this socket that will send events over inproc to the specified endpoint...
Definition: socket.cpp:835
void unsubscribe(std::string const &topic)
Unsubscribe from a topic.
Definition: socket.cpp:364
const int connect_retried
Definition: socket.hpp:48
bool receive_raw(char *buffer, size_t &length, int const flags=normal)
Definition: socket.cpp:331
const int connect_delayed
Definition: socket.hpp:47
static const int send_more
Definition: socket.hpp:84
const int closed
Definition: socket.hpp:53
void bind(endpoint_t const &endpoint)
Asynchronously binds to an endpoint.
Definition: socket.cpp:74
ZMQPP_COMPARABLE_ENUM socket_option
possible Socket options in zmq
Definition: socket_options.hpp:28
#define NOEXCEPT
Definition: compatibility.hpp:104
const int close_failed
Definition: socket.hpp:54
void track_message(message_t const &, uint32_t const, bool &)
Definition: socket.cpp:826
message message_t
message type
Definition: socket.hpp:41
void unbind(endpoint_t const &endpoint)
Unbinds from a previously bound endpoint.
Definition: socket.cpp:85
bool send_raw(char const *buffer, size_t const length, int const flags=normal)
Sends the byte data pointed to by buffer as the next part of the message.
Definition: socket.cpp:298
void connect(endpoint_t const &endpoint)
Asynchronously connects to an endpoint.
Definition: socket.cpp:96
void subscribe(InputIterator const &topics_begin, InputIterator const &topics_end)
Subscribe to a topic.
Definition: socket.hpp:330
void set(socket_option const option, int const value)
Set the value of an option in the underlaying zmq socket.
Definition: socket.cpp:376
socket(context_t const &context, socket_type const type)
Create a socket for a given type.
Definition: socket.cpp:42
void set(socket_option const option, std::string const value)
Set the value of an option in the underlaying zmq socket.
Definition: socket.hpp:445
The context class represents internal zmq context and io threads.
Definition: context.hpp:46
socket_type _type
Definition: socket.hpp:568
a zmq message with optional multipart support
Definition: message.hpp:43
std::string endpoint_t
endpoint type
Definition: socket.hpp:37
signal
Signal is a 8 bytes integer.
Definition: signal.hpp:23
ZMQPP_COMPARABLE_ENUM socket_type
Socket types allowed by zmq.
Definition: socket_types.hpp:30
void subscribe(std::string const &topic)
Subscribe to a topic.
Definition: socket.cpp:359
bool send(message_t &message, bool const dont_block=false)
Sends the message over the connection, this may be a multipart message.
Definition: socket.cpp:148
void disconnect(InputIterator const &disconnections_begin, InputIterator const &disconnections_end)
Disconnects from multiple previously connected endpoints.
Definition: socket.hpp:178
void set(socket_option const option, char const *value)
Set the value of an option in the underlaying zmq socket.
Definition: socket.hpp:437
const int bind_failed
Definition: socket.hpp:50
const int accept_failed
Definition: socket.hpp:52
bool receive(message_t &message, bool const dont_block=false)
Gets a message from the connection, this may be a multipart message.
Definition: socket.cpp:209
const int listening
Definition: socket.hpp:49
const int accepted
Definition: socket.hpp:51
const int disconnected
Definition: socket.hpp:55