Man Linux: Main Page and Category List

NAME

       zmq_socket - create 0MQ socket

SYNOPSIS

       void *zmq_socket (void *context, int type);

DESCRIPTION

       The zmq_socket() function shall create a 0MQ socket within the
       specified context and return an opaque handle to the newly created
       socket. The type argument specifies the socket type, which determines
       the semantics of communication over the socket.

       The following messaging patterns are defined:

   Peer to peer pattern
       The simplest messaging pattern, used for communicating between two
       peers.

       Socket type

           ZMQ_P2P

       Compatible peer sockets

           ZMQ_P2P

       A socket of type ZMQ_P2P can only be connected to a single peer at any
       one time. No message routing or filtering is performed on messages sent
       over a ZMQ_P2P socket.

   Publish-subscribe pattern
       The publish-subscribe pattern is used for one-to-many distribution of
       data from a single publisher to multiple subscribers in a fanout
       fashion.

       Socket type

           ZMQ_PUB

       Compatible peer sockets

           ZMQ_SUB

       A socket of type ZMQ_PUB is used by a publisher to distribute data.
       Messages sent are distributed in a fanout fashion to all connected
       peers. The zmq_recv() function is not implemented for this socket type.

       Socket type

           ZMQ_SUB

       Compatible peer sockets

           ZMQ_PUB

       A socket of type ZMQ_SUB is used by a subscriber to subscribe to data
       distributed by a publisher. Initially a ZMQ_SUB socket is not
       subscribed to any messages, use the ZMQ_SUBSCRIBE option of
       zmq_setsockopt() to specify which messages to subscribe to. The
       zmq_send() function is not implemented for this socket type.

   Request-reply pattern
       The request-reply pattern is used for sending requests from a client to
       a service, and receiving subsequent replies to each request sent.

       Socket type

           ZMQ_REQ

       Compatible peer sockets

           ZMQ_REP

       A socket of type ZMQ_REQ is used by a client to send requests to and
       receive replies from a service. This socket type allows only an
       alternating sequence of zmq_send(request) and subsequent
       zmq_recv(reply) calls. Each request sent is load-balanced among all
       connected services.

       Socket type

           ZMQ_REP

       Compatible peer sockets

           ZMQ_REQ

       A socket of type ZMQ_REP is used by a service to receive requests from
       and send replies to a client. This socket type allows only an
       alternating sequence of zmq_recv(request) and subsequent
       zmq_send(reply) calls. Each reply is routed to the client that issued
       the last received request.

   Parallelized pipeline pattern
       The parallelized pipeline pattern is used for distributing work between
       components of a pipeline. Work travels down the pipeline and at each
       stage can be processed by any number of components in parallel.

       Socket type

           ZMQ_UPSTREAM

       Compatible peer sockets

           ZMQ_DOWNSTREAM

       A socket of type ZMQ_UPSTREAM is used by a component of a pipeline to
       receive messages from upstream stages of the pipeline. Messages are
       fair-queued from among all connected upstream components. The
       zmq_send() function is not implemented for this socket type.

       Socket type

           ZMQ_DOWNSTREAM

       Compatible peer sockets

           ZMQ_UPSTREAM

       A socket of type ZMQ_DOWNSTREAM is used by a component of a pipeline to
       send messages to downstream stages of the pipeline. Messages are
       load-balanced to all connected downstream components. The zmq_recv()
       function is not implemented for this socket type.

RETURN VALUE

       The zmq_socket() function shall return an opaque handle to the newly
       created socket if successful. Otherwise, it shall return NULL and set
       errno to one of the values defined below.

ERRORS

       EINVAL
           The requested socket type is invalid.

       EMTHREAD
           The number of application threads using sockets within this context
           has been exceeded. See the app_threads parameter of the zmq_init()
           function.

SEE ALSO

       zmq_init(3) zmq_setsockopt(3) zmq_bind(3) zmq_connect(3) zmq_send(3)
       zmq_recv(3)

AUTHORS

       The 0MQ documentation was written by Martin Sustrik
       <sustrik@250bpm.com[1]> and Martin Lucina <mato@kotelna.sk[2]>.

NOTES

        1. sustrik@250bpm.com
           mailto:sustrik@250bpm.com

        2. mato@kotelna.sk
           mailto:mato@kotelna.sk