File Coverage

blib/lib/ZMQ/Raw/Socket.pm
Criterion Covered Total %
statement 25 27 92.5
branch 2 4 50.0
condition n/a
subroutine 7 8 87.5
pod n/a
total 34 39 87.1


line stmt bran cond sub pod time code
1             package ZMQ::Raw::Socket;
2             $ZMQ::Raw::Socket::VERSION = '0.39';
3 14     94   94 use strict;
  14         28  
  14         399  
4 14     94   76 use warnings;
  14         24  
  14         363  
5 14     14   68 use Carp;
  14         28  
  14         904  
6 14     14   108 use ZMQ::Raw;
  14         38  
  14         1982  
7              
8 0     0   0 sub CLONE_SKIP { 1 }
9              
10             sub AUTOLOAD
11             {
12             # This AUTOLOAD is used to 'autoload' constants from the constant()
13             # XS function.
14              
15 77     77   245 my $constname;
16 77         103 our $AUTOLOAD;
17 77         449 ($constname = $AUTOLOAD) =~ s/.*:://;
18 77 50       213 croak "&ZMQ::Raw::Socket::_constant not defined" if $constname eq '_constant';
19 77         311 my ($error, $val) = _constant ($constname);
20 77 50       143 if ($error) { croak $error; }
  0         0  
21             {
22 14     14   110 no strict 'refs';
  14         25  
  14         1722  
  77         99  
23 77     85   456 *$AUTOLOAD = sub { $val };
  85         1337  
24             }
25 77         250 goto &$AUTOLOAD;
26             }
27              
28             =head1 NAME
29              
30             ZMQ::Raw::Socket - ZeroMQ Socket class
31              
32             =head1 VERSION
33              
34             version 0.39
35              
36             =head1 DESCRIPTION
37              
38             A L represents a ZeroMQ socket.
39              
40             =head1 SYNOPSIS
41              
42             use ZMQ::Raw;
43              
44             # receive a single message-part
45             my $msg = $socket->recvmsg();
46              
47             # receive all message parts
48             my @msgs = $socket->recvmsg();
49              
50             # send multiple message parts
51             $socket->sendmsg ('hello', 'world'); # flags cannot be used here
52              
53             # or
54             my $msg1 = ZMQ::Raw::Message->new;
55             $msg1->data ('hello');
56              
57             my $msg2 = ZMQ::Raw::Message->new;
58             $msg2->data ('world');
59             $socket->sendmsg ($msg1, $msgs2, 0); # flags can be used here
60              
61             =head1 METHODS
62              
63             =head2 new( $context, $type )
64              
65             Create a new ZeroMQ socket with the specified C<$context>. C<$type> specifies
66             the socket type, which determines the semantics of communication over the
67             socket.
68              
69             =head2 bind( $endpoint )
70              
71             Bind the socket to a local endpoint which accepts incoming connections. The
72             endpoint is a string consisting of a transport:// followed by an address. The
73             transport specifies the underlying protocol to use, whereas the address
74             specifies the transport-specific address to bind to. The following transports
75             are provided:
76              
77             =over 4
78              
79             =item * "tcp"
80              
81             unicast transport using TCP
82              
83             =item * "ipc"
84              
85             local inter-process communication transport
86              
87             =item * "inproc"
88              
89             local in-process (inter-thread) communication transport
90              
91             =item * "pgm,epgm"
92              
93             reliable multicast transport using PGM
94              
95             =item * "vmci"
96              
97             virtual machine communications interface (VMCI)
98              
99             =back
100              
101             =head2 unbind( $endpoint )
102              
103             Unbind the socket from the endpoint.
104              
105             =head2 connect( $endpoint )
106              
107             Connect the socket to an endpoint which accepts incoming connections.
108              
109             =head2 disconnect( $endpoint )
110              
111             Disconnect the socket from the endpoint. Any outstanding messages physically
112             received from the network but not yet received by the application will be
113             discarded.
114              
115             =head2 send( $buffer, $flags = 0)
116              
117             Queue a message created from C<$buffer>. C<$flags> defaults to C<0> but may
118             be a combination of:
119              
120             =over 4
121              
122             =item * CZMQ_DONTWAIT>
123              
124             Perform the operation in non-blocking mode. This method will return
125             C if the message cannot be sent immediately.
126              
127             =item * CZMQ_SNDMORE>
128              
129             The message is part of a multi-part message and further message parts are to
130             follow.
131              
132             =back
133              
134             This method may return C (or an empty list if called in list context) if
135             the system call was interrupt or if the operation cannot be completed
136             immediately, after which it may be reattempted.
137              
138             =head2 close( )
139              
140             Close the socket. Any outstanding messages physically received from the network
141             but not yet received by the application will be discarded.
142              
143             =head2 monitor( $endpoint, $events)
144              
145             Track socket events. Each call to this method creates a C socket and
146             binds that to the specified inproc C<$endpoint>. In order to collect socket
147             events, you must create your own C socket and connect it to the
148             C<$endpoint>.
149              
150             =head2 sendmsg( @msgs, $flags = 0)
151              
152             Queue C<@msgs> to be sent. Each message in C<@msgs> that is a L>
153             is still valid after this call, that is, they may be reused. Each item in C<@msgs>
154             may either be a L> object or a "normal" perl scalar. The
155             C<$flags> parameter is only available if all items in C<@msgs> are L>
156             objects. See the SYNOPSIS for usage examples.
157              
158             This method may return C (or an empty list if called in list context) if
159             the system call was interrupt or if the operation cannot be completed
160             immediately, after which it may be reattempted.
161              
162             =head2 recv( $flags = 0)
163              
164             Receive a message. If there are no messages available the method will block
165             until the request can be satisfied unless the C flag is specified.
166             If a message is not available and C has been specified, this
167             method will return C immediately. If called in list context, this method
168             will return each part of the message as a scalar item. In scalar context, each
169             part of the message will be concatenated into a single scalar item.
170              
171             This method may return C (or an empty list if called in list context) if
172             the system call was interrupt or if the operation cannot be completed
173             immediately, after which it may be reattempted.
174              
175             =head2 recvmsg( $flags = 0)
176              
177             Receive a message part or multiple messages parts if called in list context.
178             Returns a L> object or an array of object.
179              
180             This method may return C (or an empty list if called in list context) if
181             the system call was interrupt or if the operation cannot be completed
182             immediately, after which it may be reattempted.
183              
184             =head2 setsockopt( $option, $value )
185              
186             Set a socket option.
187              
188             =head2 join( $group )
189              
190             Join a group.
191              
192             =head2 leave( $group )
193              
194             Leave a group.
195              
196             =head1 CONSTANTS
197              
198             =head2 ZMQ_AFFINITY
199              
200             =head2 ZMQ_IDENTITY
201              
202             =head2 ZMQ_SUBSCRIBE
203              
204             =head2 ZMQ_UNSUBSCRIBE
205              
206             =head2 ZMQ_RATE
207              
208             =head2 ZMQ_RECOVERY_IVL
209              
210             =head2 ZMQ_SNDBUF
211              
212             =head2 ZMQ_RCVBUF
213              
214             =head2 ZMQ_RCVMORE
215              
216             =head2 ZMQ_FD
217              
218             =head2 ZMQ_EVENTS
219              
220             =head2 ZMQ_TYPE
221              
222             =head2 ZMQ_LINGER
223              
224             =head2 ZMQ_RECONNECT_IVL
225              
226             =head2 ZMQ_BACKLOG
227              
228             =head2 ZMQ_RECONNECT_IVL_MAX
229              
230             =head2 ZMQ_MAXMSGSIZE
231              
232             =head2 ZMQ_SNDHWM
233              
234             =head2 ZMQ_RCVHWM
235              
236             =head2 ZMQ_MULTICAST_HOPS
237              
238             =head2 ZMQ_RCVTIMEO
239              
240             =head2 ZMQ_SNDTIMEO
241              
242             =head2 ZMQ_LAST_ENDPOINT
243              
244             =head2 ZMQ_ROUTER_MANDATORY
245              
246             =head2 ZMQ_TCP_KEEPALIVE
247              
248             =head2 ZMQ_TCP_KEEPALIVE_CNT
249              
250             =head2 ZMQ_TCP_KEEPALIVE_IDLE
251              
252             =head2 ZMQ_TCP_KEEPALIVE_INTVL
253              
254             =head2 ZMQ_IMMEDIATE
255              
256             =head2 ZMQ_XPUB_VERBOSE
257              
258             =head2 ZMQ_ROUTER_RAW
259              
260             =head2 ZMQ_IPV6
261              
262             =head2 ZMQ_MECHANISM
263              
264             =head2 ZMQ_PLAIN_SERVER
265              
266             =head2 ZMQ_PLAIN_USERNAME
267              
268             =head2 ZMQ_PLAIN_PASSWORD
269              
270             =head2 ZMQ_CURVE_SERVER
271              
272             =head2 ZMQ_CURVE_PUBLICKEY
273              
274             =head2 ZMQ_CURVE_SECRETKEY
275              
276             =head2 ZMQ_CURVE_SERVERKEY
277              
278             =head2 ZMQ_PROBE_ROUTER
279              
280             =head2 ZMQ_REQ_CORRELATE
281              
282             =head2 ZMQ_REQ_RELAXED
283              
284             =head2 ZMQ_CONFLATE
285              
286             =head2 ZMQ_ZAP_DOMAIN
287              
288             =head2 ZMQ_ROUTER_HANDOVER
289              
290             =head2 ZMQ_TOS
291              
292             =head2 ZMQ_CONNECT_RID
293              
294             =head2 ZMQ_GSSAPI_SERVER
295              
296             =head2 ZMQ_GSSAPI_PRINCIPAL
297              
298             =head2 ZMQ_GSSAPI_SERVICE_PRINCIPAL
299              
300             =head2 ZMQ_GSSAPI_PLAINTEXT
301              
302             =head2 ZMQ_HANDSHAKE_IVL
303              
304             =head2 ZMQ_SOCKS_PROXY
305              
306             =head2 ZMQ_XPUB_NODROP
307              
308             =head2 ZMQ_BLOCKY
309              
310             =head2 ZMQ_XPUB_MANUAL
311              
312             =head2 ZMQ_XPUB_WELCOME_MSG
313              
314             =head2 ZMQ_STREAM_NOTIFY
315              
316             =head2 ZMQ_INVERT_MATCHING
317              
318             =head2 ZMQ_HEARTBEAT_IVL
319              
320             =head2 ZMQ_HEARTBEAT_TTL
321              
322             =head2 ZMQ_HEARTBEAT_TIMEOUT
323              
324             =head2 ZMQ_XPUB_VERBOSER
325              
326             =head2 ZMQ_CONNECT_TIMEOUT
327              
328             =head2 ZMQ_TCP_MAXRT
329              
330             =head2 ZMQ_THREAD_SAFE
331              
332             =head2 ZMQ_MULTICAST_MAXTPDU
333              
334             =head2 ZMQ_VMCI_BUFFER_SIZE
335              
336             =head2 ZMQ_VMCI_BUFFER_MIN_SIZE
337              
338             =head2 ZMQ_VMCI_BUFFER_MAX_SIZE
339              
340             =head2 ZMQ_VMCI_CONNECT_TIMEOUT
341              
342             =head2 ZMQ_USE_FD
343              
344             =head1 AUTHOR
345              
346             Jacques Germishuys
347              
348             =head1 LICENSE AND COPYRIGHT
349              
350             Copyright 2017 Jacques Germishuys.
351              
352             This program is free software; you can redistribute it and/or modify it
353             under the terms of either: the GNU General Public License as published
354             by the Free Software Foundation; or the Artistic License.
355              
356             See http://dev.perl.org/licenses/ for more information.
357              
358             =cut
359              
360             1; # End of ZMQ::Raw::Socket