Networking Reference
In-Depth Information
Inter-process communication (IPC) is the transmission of data among processes
or threads.
TCP transport is another option you could use. However, TCP transportation
of ZeroMQ does not care whether a destination node exists or not. This is similar
to IPC.
Inter-thread transport (INPROC) has a restriction; it is mandatory to bind before
creating a connection.
Setting I/O threads and limiting the number of
ZeroMQ does I/O in the background. You could change the number of threads to
work with zmq_ctx_set by setting it before creating a socket. ZeroMQ creates one
thread by default.
void* context = zmq_ctx_new();
zmq_ctx_set(context, ZMQ_IO_THREADS, 8);
Limiting the number of sockets would be a good idea since ZeroMQ will continue
to create sockets as long as your operating system can handle it and this will make
your application vulnerable to the denial of service attacks.
void* context = zmq_ctx_new();
zmq_ctx_set(context, ZMQ_MAX_SOCKETS, 512);
Working with multiple sockets
In Chapter 1 , Getting Started , and Chapter 2 , Introduction to Sockets , we worked on
programs with a single socket. Working on one socket is easy, but working on
multiple sockets is somewhat tricky. To work with multiple sockets, we use zmq_
poll(3) , which is an event loop that allows an application to multiplex I/O with
multiple sockets.
Polling with ZeroMQ
Search MirCeyron ::

Custom Search