|Request-reply pattern||The ZMQ_REQ type is for the client that sends, then receives. The ZMQ_REP type is for the server that receives a message, then answers.|
|Publish-subscribe pattern||The ZMQ_PUB type is for publishing messages to an arbitrary number of subscribers only. The ZMQ_SUB type is for subscribers that receive messages.|
|Pipeline pattern||The ZMQ_UPSTREAM socket type sends messages in a pipeline pattern. ZMQ_DOWNSTREAM receives them.|
|Exclusive pair pattern||The ZMQ_PAIR type allows bidirectional message passing between two participants.|
Creates a new ZeroMQ::Socket.
First argument must be the ZeroMQ::Context in which the socket is to live. Second argument is the socket type.
The newly created socket is initially unbound, and not associated with any endpoints. In order to establish a message flow a socket must first be connected to at least one endpoint with the connect method or at least one endpoint must be created for accepting incoming connections with the bind method.
The bind($endpoint) method function creates an endpoint for accepting connections and binds it to the socket.
Quoting the 0MQ manual: The endpoint argument is a string consisting of two parts as follows: transport://address. The transport part specifies the underlying transport protocol to use. The meaning of the address part is specific to the underlying transport protocol selected.
The following transports are defined. Refer to the 0MQ manual for details.
With the exception of ZMQ_PAIR sockets, a single socket may be connected to multiple endpoints using connect($endpoint), while simultaneously accepting incoming connections from multiple endpoints bound to the socket using bind($endpoint)>. The exact semantics depend on the socket type.
inproc Local in-process (inter-thread) communication transport. ipc Local inter-process communication transport. tcp Unicast transport using TCP. pgm, epgm Reliable multicast transport using PGM.
Connect to an existing endpoint. Takes an enpoint string as argument, see the documentation for bind($endpoint) above.
The send($msg, $flags) method queues the given message to be sent to the socket. The flags argument is a combination of the flags defined below.
send_as( CW$type, CW$message, CW$flags )
ZMQ_NOBLOCK Specifies that the operation should be performed in non-blocking mode. If the message cannot be queued on the socket, the send() method fails with errno set to EAGAIN. ZMQ_SNDMORE Specifies that the message being sent is a multi-part message, and that further message parts are to follow. Refer to the 0MQ manual for details regarding multi-part messages.
The my $msg = $sock->recv($flags) method receives a message from the socket and returns it as a new ZeroMQ::Message object. If there are no messages available on the specified socket the recv() method blocks until the request can be satisfied. The flags argument is a combination of the flags defined below.
recv_as( CW$type, CW$flags )
ZMQ_NOBLOCK Specifies that the operation should be performed in non-blocking mode. If there are no messages available on the specified socket, the $sock->recv(ZMQ_NOBLOCK) method call returns undef and sets $ERRNO to EAGAIN.
The my $optval = $sock->getsockopt(ZMQ_SOME_OPTION) method call retrieves the value for the given socket option.
The following options can be retrieved. For a full explanation of the options, please refer to the 0MQ manual.
ZMQ_RCVMORE: More message parts to follow ZMQ_HWM: Retrieve high water mark ZMQ_SWAP: Retrieve disk offload size ZMQ_AFFINITY: Retrieve I/O thread affinity ZMQ_IDENTITY: Retrieve socket identity ZMQ_RATE: Retrieve multicast data rate ZMQ_RECOVERY_IVL: Get multicast recovery interval ZMQ_MCAST_LOOP: Control multicast loopback ZMQ_SNDBUF: Retrieve kernel transmit buffer size ZMQ_RCVBUF: Retrieve kernel receive buffer size
The $sock->setsockopt(ZMQ_SOME_OPTION, $value) method call sets the specified option to the given value.
The following socket options can be set. For details, please refer to the 0MQ manual:
ZMQ_HWM: Set high water mark ZMQ_SWAP: Set disk offload size ZMQ_AFFINITY: Set I/O thread affinity ZMQ_IDENTITY: Set socket identity ZMQ_SUBSCRIBE: Establish message filter ZMQ_UNSUBSCRIBE: Remove message filter ZMQ_RATE: Set multicast data rate ZMQ_RECOVERY_IVL: Set multicast recovery interval ZMQ_MCAST_LOOP: Control multicast loopback ZMQ_SNDBUF: Set kernel transmit buffer size ZMQ_RCVBUF: Set kernel receive buffer size
ZeroMQ::Socket objects arent thread safe due to the underlying library. Therefore, they are currently not cloned when a new Perl ithread is spawned. The variables in the new thread that contained the socket in the parent thread will be a scalar reference to undef in the new thread. This makes the Perl wrapper thread safe (i.e. no segmentation faults).
Daisuke Maki <firstname.lastname@example.org>
Steffen Mueller, <email@example.com>
The ZeroMQ module is
Copyright (C) 2010 by Daisuke Maki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.
|perl v5.20.3||ZEROMQ::SOCKET (3)||2012-01-12|