ZMQ::Raw::Socket - ZeroMQ Socket class
version 0.21
A ZMQ::Raw::Socket represents a ZeroMQ socket.
use ZMQ::Raw; # receive a single message-part my $msg = $socket->recvmsg(); # receive all message parts my @msgs = $socket->recvmsg(); # send multiple message parts $socket->sendmsg ('hello', 'world'); # flags cannot be used here # or my $msg1 = ZMQ::Raw::Message->new; $msg1->data ('hello'); my $msg2 = ZMQ::Raw::Message->new; $msg2->data ('world'); $socket->sendmsg ($msg1, $msgs2, 0); # flags can be used here
Create a new ZeroMQ socket with the specified $context. $type specifies the socket type, which determines the semantics of communication over the socket.
$context
$type
Bind the socket to a local endpoint which accepts incoming connections. The endpoint is a string consisting of a transport:// followed by an address. The transport specifies the underlying protocol to use, whereas the address specifies the transport-specific address to bind to. The following transports are provided:
"tcp"
unicast transport using TCP
"ipc"
local inter-process communication transport
"inproc"
local in-process (inter-thread) communication transport
"pgm,epgm"
reliable multicast transport using PGM
"vmci"
virtual machine communications interface (VMCI)
Unbind the socket from the endpoint.
Connect the socket to an endpoint which accepts incoming connections.
Disconnect the socket from the endpoint. Any outstanding messages physically received from the network but not yet received by the application will be discarded.
Queue a message created from $buffer. $flags defaults to 0 but may be a combination of:
$buffer
$flags
0
ZMQ::Raw->ZMQ_DONTWAIT
Perform the operation in non-blocking mode. This method will return undef if the message cannot be sent immediately.
undef
ZMQ::Raw->ZMQ_SNDMORE
The message is part of a multi-part message and further message parts are to follow.
This method may return undef (or an empty list if called in list context) if the system call was interrupt or if the operation cannot be completed immediately, after which it may be reattempted.
Close the socket. Any outstanding messages physically received from the network but not yet received by the application will be discarded.
Track socket events. Each call to this method creates a ZMQ_PAIR socket and binds that to the specified inproc $endpoint. In order to collect socket events, you must create your own ZMQ_PAIR socket and connect it to the $endpoint.
ZMQ_PAIR
$endpoint
Queue @msgs to be sent. Each message in @msgs that is a ZMQ::Raw::Message is still valid after this call, that is, they may be reused. Each item in @msgs may either be a ZMQ::Raw::Message object or a "normal" perl scalar. The $flags parameter is only available if all items in @msgs are ZMQ::Raw::Message objects. See the SYNOPSIS for usage examples.
@msgs
ZMQ::Raw::Message
Receive a message. If there are no messages available the method will block until the request can be satisfied unless the ZMQ_DONTWAIT flag is specified. If a message is not available and ZMQ_DONTWAIT has been specified, this method will return undef immediately. If called in list context, this method will return each part of the message as a scalar item. In scalar context, each part of the message will be concatenated into a single scalar item.
ZMQ_DONTWAIT
Receive a message part or multiple messages parts if called in list context. Returns a ZMQ::Raw::Message object or an array of object.
Set a socket option.
Join a group.
Leave a group.
Jacques Germishuys <jacquesg@striata.com>
Copyright 2017 Jacques Germishuys.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install ZMQ::Raw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZMQ::Raw
CPAN shell
perl -MCPAN -e shell install ZMQ::Raw
For more information on module installation, please visit the detailed CPAN module installation guide.