libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
zmq.cpp File Reference
#include "precompiled.hpp"
#include "macros.hpp"
#include "poller.hpp"
#include <poll.h>
#include "../include/zmq.h"
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <new>
#include <climits>
#include "proxy.hpp"
#include "socket_base.hpp"
#include "stdint.hpp"
#include "config.hpp"
#include "likely.hpp"
#include "clock.hpp"
#include "ctx.hpp"
#include "err.hpp"
#include "msg.hpp"
#include "fd.hpp"
#include "metadata.hpp"
#include "signaler.hpp"
#include "socket_poller.hpp"
#include "timers.hpp"
Include dependency graph for zmq.cpp:

Go to the source code of this file.

Classes

struct  iovec
 

Macros

#define ZMQ_TYPE_UNSAFE
 

Typedefs

typedef char check_msg_t_size[sizeof(zmq::msg_t)==sizeof(zmq_msg_t)?1:-1]
 

Functions

static int s_recvmsg (zmq::socket_base_t *s_, zmq_msg_t *msg_, int flags_)
 
static int s_sendmsg (zmq::socket_base_t *s_, zmq_msg_t *msg_, int flags_)
 
int zmq_bind (void *s_, const char *addr_)
 
int zmq_close (void *s_)
 
int zmq_connect (void *s_, const char *addr_)
 
int zmq_ctx_destroy (void *ctx_)
 
int zmq_ctx_get (void *ctx_, int option_)
 
void * zmq_ctx_new (void)
 
int zmq_ctx_set (void *ctx_, int option_, int optval_)
 
int zmq_ctx_shutdown (void *ctx_)
 
int zmq_ctx_term (void *ctx_)
 
int zmq_device (int, void *frontend_, void *backend_)
 
int zmq_disconnect (void *s_, const char *addr_)
 
int zmq_errno (void)
 
int zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_)
 
int zmq_has (const char *capability)
 
void * zmq_init (int io_threads_)
 
int zmq_join (void *s_, const char *group_)
 
int zmq_leave (void *s_, const char *group_)
 
int zmq_msg_close (zmq_msg_t *msg_)
 
int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_)
 
void * zmq_msg_data (zmq_msg_t *msg_)
 
int zmq_msg_get (zmq_msg_t *msg_, int property_)
 
const char * zmq_msg_gets (zmq_msg_t *msg_, const char *property_)
 
const char * zmq_msg_group (zmq_msg_t *msg_)
 
int zmq_msg_init (zmq_msg_t *msg_)
 
int zmq_msg_init_data (zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_)
 
int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_)
 
int zmq_msg_more (zmq_msg_t *msg_)
 
int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_)
 
int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_)
 
uint32_t zmq_msg_routing_id (zmq_msg_t *msg_)
 
int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_)
 
int zmq_msg_set (zmq_msg_t *, int, int)
 
int zmq_msg_set_group (zmq_msg_t *msg_, const char *group_)
 
int zmq_msg_set_routing_id (zmq_msg_t *msg_, uint32_t routing_id_)
 
size_t zmq_msg_size (zmq_msg_t *msg_)
 
int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
 
int zmq_poller_add (void *poller_, void *s_, void *user_data_, short events_)
 
int zmq_poller_add_fd (void *poller_, int fd_, void *user_data_, short events_)
 
int zmq_poller_destroy (void **poller_p_)
 
int zmq_poller_modify (void *poller_, void *s_, short events_)
 
int zmq_poller_modify_fd (void *poller_, int fd_, short events_)
 
void * zmq_poller_new (void)
 
int zmq_poller_remove (void *poller_, void *s_)
 
int zmq_poller_remove_fd (void *poller_, int fd_)
 
int zmq_poller_wait (void *poller_, zmq_poller_event_t *event, long timeout_)
 
int zmq_proxy (void *frontend_, void *backend_, void *capture_)
 
int zmq_proxy_steerable (void *frontend_, void *backend_, void *capture_, void *control_)
 
int zmq_recv (void *s_, void *buf_, size_t len_, int flags_)
 
int zmq_recviov (void *s_, iovec *a_, size_t *count_, int flags_)
 
int zmq_recvmsg (void *s_, zmq_msg_t *msg_, int flags_)
 
int zmq_send (void *s_, const void *buf_, size_t len_, int flags_)
 
int zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_)
 
int zmq_sendiov (void *s_, iovec *a_, size_t count_, int flags_)
 
int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_)
 
int zmq_setsockopt (void *s_, int option_, const void *optval_, size_t optvallen_)
 
void * zmq_socket (void *ctx_, int type_)
 
int zmq_socket_monitor (void *s_, const char *addr_, int events_)
 
const char * zmq_strerror (int errnum_)
 
int zmq_term (void *ctx_)
 
int zmq_timers_add (void *timers_, size_t interval_, zmq_timer_fn handler_, void *arg_)
 
int zmq_timers_cancel (void *timers_, int timer_id_)
 
int zmq_timers_destroy (void **timers_p_)
 
int zmq_timers_execute (void *timers_)
 
void * zmq_timers_new (void)
 
int zmq_timers_reset (void *timers_, int timer_id_)
 
int zmq_timers_set_interval (void *timers_, int timer_id_, size_t interval_)
 
long zmq_timers_timeout (void *timers_)
 
int zmq_unbind (void *s_, const char *addr_)
 
void zmq_version (int *major_, int *minor_, int *patch_)
 

Macro Definition Documentation

#define ZMQ_TYPE_UNSAFE

Definition at line 30 of file zmq.cpp.

Typedef Documentation

typedef char check_msg_t_size[sizeof(zmq::msg_t)== sizeof(zmq_msg_t)?1:-1]

Definition at line 91 of file zmq.cpp.

Function Documentation

static int s_recvmsg ( zmq::socket_base_t s_,
zmq_msg_t msg_,
int  flags_ 
)
static

Definition at line 489 of file zmq.cpp.

References zmq::socket_base_t::recv(), unlikely, and zmq_msg_size().

Referenced by zmq_msg_recv(), zmq_recv(), and zmq_recviov().

Here is the call graph for this function:

Here is the caller graph for this function:

static int s_sendmsg ( zmq::socket_base_t s_,
zmq_msg_t msg_,
int  flags_ 
)
inlinestatic

Definition at line 366 of file zmq.cpp.

References zmq::socket_base_t::send(), unlikely, and zmq_msg_size().

Referenced by zmq_msg_send(), zmq_send(), zmq_send_const(), and zmq_sendiov().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_ctx_destroy ( void *  ctx_)

Definition at line 236 of file zmq.cpp.

References zmq_ctx_term().

Referenced by main(), test_ctx_destroy(), test_ctx_shutdown(), test_router_2_router(), test_stream_2_stream(), test_system_max(), and test_zmq_default_max().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_ctx_get ( void *  ctx_,
int  option_ 
)

Definition at line 209 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

int zmq_ctx_set ( void *  ctx_,
int  option_,
int  optval_ 
)

Definition at line 200 of file zmq.cpp.

Referenced by main(), test_system_max(), and zmq_init().

Here is the caller graph for this function:

int zmq_ctx_shutdown ( void *  ctx_)

Definition at line 191 of file zmq.cpp.

Referenced by test_ctx_shutdown(), and test_shutdown_during_pend().

Here is the caller graph for this function:

int zmq_device ( int  ,
void *  frontend_,
void *  backend_ 
)

Definition at line 1350 of file zmq.cpp.

References zmq::proxy().

Here is the call graph for this function:

int zmq_disconnect ( void *  s_,
const char *  addr_ 
)

Definition at line 353 of file zmq.cpp.

References ENOTSOCK, and zmq::socket_base_t::term_endpoint().

Referenced by main(), and test_destroy_queue_on_disconnect().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_has ( const char *  capability)

Definition at line 1359 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

void* zmq_init ( int  io_threads_)

Definition at line 220 of file zmq.cpp.

References zmq_ctx_new(), zmq_ctx_set(), and ZMQ_IO_THREADS.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_join ( void *  s_,
const char *  group_ 
)

Definition at line 299 of file zmq.cpp.

References ENOTSOCK, and zmq::socket_base_t::join().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_leave ( void *  s_,
const char *  group_ 
)

Definition at line 310 of file zmq.cpp.

References ENOTSOCK, and zmq::socket_base_t::leave().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_msg_copy ( zmq_msg_t dest_,
zmq_msg_t src_ 
)

Definition at line 661 of file zmq.cpp.

Referenced by bounce(), main(), and test_req_message_format().

Here is the caller graph for this function:

int zmq_msg_get ( zmq_msg_t msg_,
int  property_ 
)

Definition at line 681 of file zmq.cpp.

References zmq::msg_t::more, zmq::msg_t::shared, ZMQ_MORE, zmq_msg_gets(), ZMQ_SHARED, and ZMQ_SRCFD.

Referenced by main(), and zmq_msg_more().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* zmq_msg_gets ( zmq_msg_t msg_,
const char *  property_ 
)

Definition at line 732 of file zmq.cpp.

References zmq::metadata_t::get().

Referenced by main(), test_stream_to_dealer(), and zmq_msg_get().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* zmq_msg_group ( zmq_msg_t msg_)

Definition at line 725 of file zmq.cpp.

Referenced by msg_recv_cmp().

Here is the caller graph for this function:

int zmq_msg_init_data ( zmq_msg_t msg_,
void *  data_,
size_t  size_,
zmq_free_fn ffn_,
void *  hint_ 
)

Definition at line 623 of file zmq.cpp.

Referenced by main(), and zmq_send_const().

Here is the caller graph for this function:

int zmq_msg_init_size ( zmq_msg_t msg_,
size_t  size_ 
)

Definition at line 618 of file zmq.cpp.

Referenced by main(), zmq::socket_base_t::monitor_event(), msg_send(), test_client_server(), worker(), zmq_send(), and zmq_sendiov().

Here is the caller graph for this function:

int zmq_msg_more ( zmq_msg_t msg_)

Definition at line 676 of file zmq.cpp.

References ZMQ_MORE, and zmq_msg_get().

Referenced by get_monitor_event(), main(), test_identity(), and test_stream_to_dealer().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_msg_move ( zmq_msg_t dest_,
zmq_msg_t src_ 
)

Definition at line 656 of file zmq.cpp.

uint32_t zmq_msg_routing_id ( zmq_msg_t msg_)

Definition at line 715 of file zmq.cpp.

Referenced by main(), and test_client_server().

Here is the caller graph for this function:

int zmq_msg_send ( zmq_msg_t msg_,
void *  s_,
int  flags_ 
)

Definition at line 629 of file zmq.cpp.

References ENOTSOCK, and s_sendmsg().

Referenced by bounce(), main(), msg_send(), test_client_server(), test_req_message_format(), test_stream_to_dealer(), and zmq_sendmsg().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_msg_set ( zmq_msg_t ,
int  ,
int   
)

Definition at line 703 of file zmq.cpp.

int zmq_msg_set_group ( zmq_msg_t msg_,
const char *  group_ 
)

Definition at line 720 of file zmq.cpp.

Referenced by msg_send().

Here is the caller graph for this function:

int zmq_msg_set_routing_id ( zmq_msg_t msg_,
uint32_t  routing_id_ 
)

Definition at line 710 of file zmq.cpp.

Referenced by main(), and test_client_server().

Here is the caller graph for this function:

size_t zmq_msg_size ( zmq_msg_t msg_)

Definition at line 671 of file zmq.cpp.

Referenced by get_monitor_event(), main(), msg_recv_cmp(), s_recv_seq(), s_recvmsg(), s_sendmsg(), test_req_message_format(), and zmq_recviov().

Here is the caller graph for this function:

int zmq_poll ( zmq_pollitem_t items_,
int  nitems_,
long  timeout_ 
)
int zmq_poller_add ( void *  poller_,
void *  s_,
void *  user_data_,
short  events_ 
)

Definition at line 1124 of file zmq.cpp.

References ENOTSOCK, and zmq_poller_add_fd().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_poller_add_fd ( void *  poller_,
int  fd_,
void *  user_data_,
short  events_ 
)

Definition at line 1143 of file zmq.cpp.

Referenced by main(), and zmq_poller_add().

Here is the caller graph for this function:

int zmq_poller_destroy ( void **  poller_p_)

Definition at line 1111 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

int zmq_poller_modify ( void *  poller_,
void *  s_,
short  events_ 
)

Definition at line 1155 of file zmq.cpp.

References ENOTSOCK, and zmq_poller_modify_fd().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_poller_modify_fd ( void *  poller_,
int  fd_,
short  events_ 
)

Definition at line 1175 of file zmq.cpp.

Referenced by zmq_poller_modify().

Here is the caller graph for this function:

void* zmq_poller_new ( void  )

Definition at line 1104 of file zmq.cpp.

References alloc_assert.

Referenced by main().

Here is the caller graph for this function:

int zmq_poller_remove ( void *  poller_,
void *  s_ 
)

Definition at line 1187 of file zmq.cpp.

References ENOTSOCK, and zmq_poller_remove_fd().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_poller_remove_fd ( void *  poller_,
int  fd_ 
)

Definition at line 1206 of file zmq.cpp.

Referenced by main(), and zmq_poller_remove().

Here is the caller graph for this function:

int zmq_poller_wait ( void *  poller_,
zmq_poller_event_t event,
long  timeout_ 
)

Definition at line 1218 of file zmq.cpp.

References zmq::socket_poller_t::event_t::events, zmq::socket_poller_t::event_t::fd, zmq::socket_poller_t::event_t::socket, zmq::socket_poller_t::event_t::user_data, and zmq_assert.

Referenced by main().

Here is the caller graph for this function:

int zmq_proxy ( void *  frontend_,
void *  backend_,
void *  capture_ 
)

Definition at line 1323 of file zmq.cpp.

References zmq::proxy().

Here is the call graph for this function:

int zmq_proxy_steerable ( void *  frontend_,
void *  backend_,
void *  capture_,
void *  control_ 
)

Definition at line 1335 of file zmq.cpp.

References zmq::proxy().

Referenced by server_task().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_recviov ( void *  s_,
iovec a_,
size_t *  count_,
int  flags_ 
)

Definition at line 557 of file zmq.cpp.

References ENOTSOCK, errno_assert, zmq::msg_t::flags, iovec::iov_base, iovec::iov_len, zmq::msg_t::more, s_recvmsg(), unlikely, zmq_msg_close(), zmq_msg_data(), zmq_msg_init(), and zmq_msg_size().

Referenced by do_check().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_recvmsg ( void *  s_,
zmq_msg_t msg_,
int  flags_ 
)

Definition at line 501 of file zmq.cpp.

References zmq_msg_recv().

Referenced by main(), and worker().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_send_const ( void *  s_,
const void *  buf_,
size_t  len_,
int  flags_ 
)

Definition at line 416 of file zmq.cpp.

References ENOTSOCK, errno_assert, s_sendmsg(), unlikely, zmq_msg_close(), and zmq_msg_init_data().

Referenced by main(), pusher(), test_basic(), test_bind_before_connect(), test_connect_before_bind(), test_connect_before_bind_pub_sub(), test_multiple_connects(), test_router_2_router(), and test_unbind().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_sendiov ( void *  s_,
iovec a_,
size_t  count_,
int  flags_ 
)

Definition at line 449 of file zmq.cpp.

References ENOTSOCK, errno_assert, iovec::iov_base, iovec::iov_len, s_sendmsg(), unlikely, zmq_msg_close(), zmq_msg_data(), zmq_msg_init_size(), and ZMQ_SNDMORE.

Referenced by do_check().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_sendmsg ( void *  s_,
zmq_msg_t msg_,
int  flags_ 
)

Definition at line 382 of file zmq.cpp.

References zmq_msg_send().

Referenced by main(), zmq::socket_base_t::monitor_event(), and worker().

Here is the call graph for this function:

Here is the caller graph for this function:

void* zmq_socket ( void *  ctx_,
int  type_ 
)

Definition at line 244 of file zmq.cpp.

References zmq::ctx_t::create_socket().

Referenced by client_task(), count_msg(), main(), zmq::socket_base_t::monitor(), prep_server_socket(), pusher(), run_test(), server_task(), server_worker(), simult_bind(), simult_conn(), test_basic(), test_bind_before_connect(), test_block_on_send_no_peers(), test_blocking(), test_change_after_connected(), test_change_before_connected(), test_client_server(), test_connect_before_bind(), test_connect_before_bind_pub_sub(), test_connect_only(), test_ctx_destroy(), test_ctx_shutdown(), test_decrease_when_full(), test_defaults(), test_destroy_queue_on_disconnect(), test_envelope(), test_fair_queue_in(), test_heartbeat_notimeout(), test_heartbeat_ttl(), test_identity(), test_inproc_bind_and_close_first(), test_inproc_connect_and_close_first(), test_missing_subscriptions(), test_multiple_connects(), test_multiple_threads(), test_pair(), test_pull_fair_queue_in(), test_push_block_on_send_no_peers(), test_push_round_robin_out(), test_req_message_format(), test_req_only_listens_to_current_peer(), test_req_rep(), test_reset_hwm(), test_round_robin_out(), test_router_2_router(), test_setsockopt_tcp_recv_buffer(), test_setsockopt_tcp_send_buffer(), test_setsockopt_use_fd(), test_shutdown_during_pend(), test_stream_2_stream(), test_stream_handshake_timeout_accept(), test_stream_handshake_timeout_connect(), test_stream_to_dealer(), test_stream_to_stream(), test_system_max(), test_unbind(), test_xpub_proxy_unsubscribe_on_disconnect(), test_zmq_default_max(), worker(), and zap_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_socket_monitor ( void *  s_,
const char *  addr_,
int  events_ 
)

Definition at line 288 of file zmq.cpp.

References ENOTSOCK, and zmq::socket_base_t::monitor().

Referenced by main(), prep_server_socket(), test_stream_handshake_timeout_accept(), and test_stream_handshake_timeout_connect().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* zmq_strerror ( int  errnum_)

Definition at line 102 of file zmq.cpp.

References zmq::errno_to_string().

Referenced by main(), and worker().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq_term ( void *  ctx_)

Definition at line 231 of file zmq.cpp.

References zmq_ctx_term().

Here is the call graph for this function:

int zmq_timers_add ( void *  timers_,
size_t  interval_,
zmq_timer_fn  handler_,
void *  arg_ 
)

Definition at line 1261 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

int zmq_timers_cancel ( void *  timers_,
int  timer_id_ 
)

Definition at line 1271 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

int zmq_timers_destroy ( void **  timers_p_)

Definition at line 1249 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

int zmq_timers_execute ( void *  timers_)

Definition at line 1311 of file zmq.cpp.

Referenced by main(), and sleep_and_execute().

Here is the caller graph for this function:

void* zmq_timers_new ( void  )

Definition at line 1242 of file zmq.cpp.

References alloc_assert.

Referenced by main().

Here is the caller graph for this function:

int zmq_timers_reset ( void *  timers_,
int  timer_id_ 
)

Definition at line 1291 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

int zmq_timers_set_interval ( void *  timers_,
int  timer_id_,
size_t  interval_ 
)

Definition at line 1281 of file zmq.cpp.

Referenced by main().

Here is the caller graph for this function:

long zmq_timers_timeout ( void *  timers_)

Definition at line 1301 of file zmq.cpp.

Referenced by main(), and sleep_and_execute().

Here is the caller graph for this function:

int zmq_unbind ( void *  s_,
const char *  addr_ 
)

Definition at line 343 of file zmq.cpp.

References ENOTSOCK, and zmq::socket_base_t::term_endpoint().

Referenced by main(), test_router_2_router(), test_stream_2_stream(), and test_unbind().

Here is the call graph for this function:

Here is the caller graph for this function:

void zmq_version ( int major_,
int minor_,
int patch_ 
)

Definition at line 94 of file zmq.cpp.

References ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, and ZMQ_VERSION_PATCH.

Referenced by main().

Here is the caller graph for this function: