~ubuntu-branches/ubuntu/trusty/zeromq3/trusty

« back to all changes in this revision

Viewing changes to doc/zmq_socket.html

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-06-12 10:53:58 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120612105358-irh7e8ivwc4566fi
Tags: 3.2.0~rc1+dfsg-1
* New upstream RC release
* Use repack.{local,stub} instead of get-orig-source rule
* Add 01_fix-unused-variable-error.patch
* Remove build dependency on uuid-dev (no more needed)
* Add 02_check-ifdef-SO_NOSIGPIPE.patch to fix kfreebsd build
* Add 03_fix-test_shutdown_stress-segfault.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
4
<head>
5
5
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
6
 
<meta name="generator" content="AsciiDoc 8.6.3" />
 
6
<meta name="generator" content="AsciiDoc 8.6.4" />
7
7
<title>zmq_socket(3)</title>
8
8
<style type="text/css">
9
9
/* Sans-serif font. */
394
394
  font-size: 0.9em;
395
395
}
396
396
 
 
397
span.aqua { color: aqua; }
 
398
span.black { color: black; }
 
399
span.blue { color: blue; }
 
400
span.fuchsia { color: fuchsia; }
 
401
span.gray { color: gray; }
 
402
span.green { color: green; }
 
403
span.lime { color: lime; }
 
404
span.maroon { color: maroon; }
 
405
span.navy { color: navy; }
 
406
span.olive { color: olive; }
 
407
span.purple { color: purple; }
 
408
span.red { color: red; }
 
409
span.silver { color: silver; }
 
410
span.teal { color: teal; }
 
411
span.white { color: white; }
 
412
span.yellow { color: yellow; }
 
413
 
 
414
span.aqua-background { background: aqua; }
 
415
span.black-background { background: black; }
 
416
span.blue-background { background: blue; }
 
417
span.fuchsia-background { background: fuchsia; }
 
418
span.gray-background { background: gray; }
 
419
span.green-background { background: green; }
 
420
span.lime-background { background: lime; }
 
421
span.maroon-background { background: maroon; }
 
422
span.navy-background { background: navy; }
 
423
span.olive-background { background: olive; }
 
424
span.purple-background { background: purple; }
 
425
span.red-background { background: red; }
 
426
span.silver-background { background: silver; }
 
427
span.teal-background { background: teal; }
 
428
span.white-background { background: white; }
 
429
span.yellow-background { background: yellow; }
 
430
 
 
431
span.big { font-size: 2em; }
 
432
span.small { font-size: 0.6em; }
397
433
/* Overrides for manpage documents */
398
434
h1 {
399
435
  padding-top: 0.5em;
598
634
<div class="paragraph"><div class="title">Thread safety</div><p>ØMQ <em>sockets</em> are <em>not</em> thread safe. Applications MUST NOT use a socket
599
635
from multiple threads except after migrating a socket from one thread to
600
636
another with a "full fence" memory barrier.</p></div>
601
 
<div class="paragraph"><div class="title">Socket types</div><p>ØMQ defines several messaging patterns which encapsulate exact semantics of
602
 
a particular topology. For example, publush-subscribe pattern defines data
603
 
distribution trees while request-reply defines networks of shared stateless
604
 
services. Each pattern defines several socket types (roles in the pattern).</p></div>
605
 
<div class="paragraph"><p>The following sections present the socket types defined by ØMQ:</p></div>
 
637
<div class="paragraph"><div class="title">Socket types</div><p>The following sections present the socket types defined by ØMQ, grouped by the
 
638
general <em>messaging pattern</em> which is built from related socket types.</p></div>
606
639
<div class="sect2">
607
640
<h3 id="_request_reply_pattern">Request-reply pattern</h3>
608
641
<div class="paragraph"><p>The request-reply pattern is used for sending requests from a <em>client</em> to one
609
 
or more instances of a stateless <em>service</em>, and receiving subsequent replies
610
 
to each request sent.</p></div>
 
642
or more instances of a <em>service</em>, and receiving subsequent replies to each
 
643
request sent.</p></div>
611
644
<div class="sect3">
612
645
<h4 id="_zmq_req">ZMQ_REQ</h4>
613
646
<div class="paragraph"><p>A socket of type <em>ZMQ_REQ</em> is used by a <em>client</em> to send requests to and
614
647
receive replies from a <em>service</em>. This socket type allows only an alternating
615
648
sequence of <em>zmq_send(request)</em> and subsequent <em>zmq_recv(reply)</em> calls. Each
616
 
request sent is load-balanced among all <em>services</em>, and each reply received is
 
649
request sent is round-robined among all <em>services</em>, and each reply received is
617
650
matched with the last issued request.</p></div>
618
651
<div class="paragraph"><p>When a <em>ZMQ_REQ</em> socket enters an exceptional state due to having reached the
619
652
high water mark for all <em>services</em>, or if there are no <em>services</em> at all, then
628
661
</td>
629
662
<td class="hdlist2">
630
663
<p style="margin-top: 0;">
631
 
<em>ZMQ_REP</em>
 
664
<em>ZMQ_REP</em>, <em>ZMQ_ROUTER</em>
 
665
</p>
 
666
</td>
 
667
</tr>
 
668
<tr>
 
669
<td class="hdlist1">
 
670
Direction
 
671
<br />
 
672
</td>
 
673
<td class="hdlist2">
 
674
<p style="margin-top: 0;">
 
675
Bidirectional
632
676
</p>
633
677
</td>
634
678
</tr>
650
694
</td>
651
695
<td class="hdlist2">
652
696
<p style="margin-top: 0;">
653
 
Load-balanced
 
697
Round-robin
654
698
</p>
655
699
</td>
656
700
</tr>
697
741
</td>
698
742
<td class="hdlist2">
699
743
<p style="margin-top: 0;">
700
 
<em>ZMQ_REQ</em>
 
744
<em>ZMQ_REQ</em>, <em>ZMQ_DEALER</em>
 
745
</p>
 
746
</td>
 
747
</tr>
 
748
<tr>
 
749
<td class="hdlist1">
 
750
Direction
 
751
<br />
 
752
</td>
 
753
<td class="hdlist2">
 
754
<p style="margin-top: 0;">
 
755
Bidirectional
701
756
</p>
702
757
</td>
703
758
</tr>
748
803
</table></div>
749
804
</div>
750
805
<div class="sect3">
751
 
<h4 id="_zmq_xreq">ZMQ_XREQ</h4>
752
 
<div class="paragraph"><p>A socket of type <em>ZMQ_XREQ</em> is a socket type underlying <em>ZMQ_REQ</em>. It doesn&#8217;t
753
 
impose the strict order of sends and recvs as <em>ZMQ_REQ</em> does and it is
754
 
intended for use in intermediate devices in request-reply topologies.</p></div>
755
 
<div class="paragraph"><p>Each message sent is load-balanced among all connected
 
806
<h4 id="_zmq_dealer">ZMQ_DEALER</h4>
 
807
<div class="paragraph"><p>A socket of type <em>ZMQ_DEALER</em> is an advanced pattern used for extending
 
808
request/reply sockets. Each message sent is round-robined among all connected
756
809
peers, and each message received is fair-queued from all connected peers.</p></div>
757
 
<div class="paragraph"><p>When a <em>ZMQ_XREQ</em> socket enters an exceptional state due to having reached the
 
810
<div class="paragraph"><p>When a <em>ZMQ_DEALER</em> socket enters an exceptional state due to having reached the
758
811
high water mark for all peers, or if there are no peers at all, then any
759
812
<a href="zmq_send.html">zmq_send(3)</a> operations on the socket shall block until the exceptional
760
813
state ends or at least one peer becomes available for sending; messages are not
761
814
discarded.</p></div>
762
 
<div class="hdlist"><div class="title">Summary of ZMQ_XREQ characteristics</div><table>
 
815
<div class="paragraph"><p>When a <em>ZMQ_DEALER</em> socket is connected to a <em>ZMQ_REP</em> socket each message sent
 
816
must consist of an empty message part, the <em>delimiter</em>, followed by one or more
 
817
<em>body parts</em>.</p></div>
 
818
<div class="paragraph"><p>Deprecated alias: <em>ZMQ_XREQ</em>.</p></div>
 
819
<div class="hdlist"><div class="title">Summary of ZMQ_DEALER characteristics</div><table>
763
820
<tr>
764
821
<td class="hdlist1">
765
822
Compatible peer sockets
767
824
</td>
768
825
<td class="hdlist2">
769
826
<p style="margin-top: 0;">
770
 
<em>ZMQ_XREP</em>, <em>ZMQ_REP</em>
 
827
<em>ZMQ_ROUTER</em>, <em>ZMQ_REP</em>
 
828
</p>
 
829
</td>
 
830
</tr>
 
831
<tr>
 
832
<td class="hdlist1">
 
833
Direction
 
834
<br />
 
835
</td>
 
836
<td class="hdlist2">
 
837
<p style="margin-top: 0;">
 
838
Bidirectional
771
839
</p>
772
840
</td>
773
841
</tr>
789
857
</td>
790
858
<td class="hdlist2">
791
859
<p style="margin-top: 0;">
792
 
Load-balanced
 
860
Round-robin
793
861
</p>
794
862
</td>
795
863
</tr>
818
886
</table></div>
819
887
</div>
820
888
<div class="sect3">
821
 
<h4 id="_zmq_xrep">ZMQ_XREP</h4>
822
 
<div class="paragraph"><p>A socket of type <em>ZMQ_XREP</em> is a socket type underlying <em>ZMQ_REP</em>. It doesn&#8217;t
823
 
impose the strict order of sends and recvs as <em>ZMQ_REQ</em> does and it is
824
 
intended for use in intermediate devices in request-reply topologies.</p></div>
825
 
<div class="paragraph"><p>Messages received are fair-queued from among all connected peers. The outbound
826
 
messages are routed to a specific peer, as explained below.</p></div>
827
 
<div class="paragraph"><p>When a <em>ZMQ_XREP</em> socket enters an exceptional state due to having reached the
 
889
<h4 id="_zmq_router">ZMQ_ROUTER</h4>
 
890
<div class="paragraph"><p>A socket of type <em>ZMQ_ROUTER</em> is an advanced socket type used for extending
 
891
request/reply sockets. When receiving messages a <em>ZMQ_ROUTER</em> socket shall
 
892
prepend a message part containing the <em>identity</em> of the originating peer to the
 
893
message before passing it to the application. Messages received are fair-queued
 
894
from among all connected peers. When sending messages a <em>ZMQ_ROUTER</em> socket shall
 
895
remove the first part of the message and use it to determine the <em>identity</em> of
 
896
the peer the message shall be routed to. If the peer does not exist anymore
 
897
the message shall be silently discarded.</p></div>
 
898
<div class="paragraph"><p>When a <em>ZMQ_ROUTER</em> socket enters an exceptional state due to having reached the
828
899
high water mark for all peers, or if there are no peers at all, then any
829
900
messages sent to the socket shall be dropped until the exceptional state ends.
830
 
Likewise, any messages to be routed to a non-existent peer or a peer for which
831
 
the individual high water mark has been reached shall also be dropped.</p></div>
832
 
<div class="hdlist"><div class="title">Summary of ZMQ_XREP characteristics</div><table>
 
901
Likewise, any messages routed to a non-existent peer or a peer for which the
 
902
individual high water mark has been reached shall also be dropped.</p></div>
 
903
<div class="paragraph"><p>When a <em>ZMQ_REQ</em> socket is connected to a <em>ZMQ_ROUTER</em> socket, in addition to the
 
904
<em>identity</em> of the originating peer each message received shall contain an empty
 
905
<em>delimiter</em> message part. Hence, the entire structure of each received message
 
906
as seen by the application becomes: one or more <em>identity</em> parts, <em>delimiter</em>
 
907
part, one or more <em>body parts</em>. When sending replies to a <em>ZMQ_REQ</em> socket the
 
908
application must include the <em>delimiter</em> part.</p></div>
 
909
<div class="paragraph"><p>Deprecated alias: <em>ZMQ_XREP</em>.</p></div>
 
910
<div class="hdlist"><div class="title">Summary of ZMQ_ROUTER characteristics</div><table>
833
911
<tr>
834
912
<td class="hdlist1">
835
913
Compatible peer sockets
837
915
</td>
838
916
<td class="hdlist2">
839
917
<p style="margin-top: 0;">
840
 
<em>ZMQ_XREQ</em>, <em>ZMQ_REQ</em>
 
918
<em>ZMQ_DEALER</em>, 'ZMQ_REQ
 
919
</p>
 
920
</td>
 
921
</tr>
 
922
<tr>
 
923
<td class="hdlist1">
 
924
Direction
 
925
<br />
 
926
</td>
 
927
<td class="hdlist2">
 
928
<p style="margin-top: 0;">
 
929
Bidirectional
841
930
</p>
842
931
</td>
843
932
</tr>
915
1004
</tr>
916
1005
<tr>
917
1006
<td class="hdlist1">
 
1007
Direction
 
1008
<br />
 
1009
</td>
 
1010
<td class="hdlist2">
 
1011
<p style="margin-top: 0;">
 
1012
Unidirectional
 
1013
</p>
 
1014
</td>
 
1015
</tr>
 
1016
<tr>
 
1017
<td class="hdlist1">
918
1018
Send/receive pattern
919
1019
<br />
920
1020
</td>
980
1080
</tr>
981
1081
<tr>
982
1082
<td class="hdlist1">
 
1083
Direction
 
1084
<br />
 
1085
</td>
 
1086
<td class="hdlist2">
 
1087
<p style="margin-top: 0;">
 
1088
Unidirectional
 
1089
</p>
 
1090
</td>
 
1091
</tr>
 
1092
<tr>
 
1093
<td class="hdlist1">
983
1094
Send/receive pattern
984
1095
<br />
985
1096
</td>
1044
1155
</tr>
1045
1156
<tr>
1046
1157
<td class="hdlist1">
 
1158
Direction
 
1159
<br />
 
1160
</td>
 
1161
<td class="hdlist2">
 
1162
<p style="margin-top: 0;">
 
1163
Unidirectional
 
1164
</p>
 
1165
</td>
 
1166
</tr>
 
1167
<tr>
 
1168
<td class="hdlist1">
1047
1169
Send/receive pattern
1048
1170
<br />
1049
1171
</td>
1107
1229
</tr>
1108
1230
<tr>
1109
1231
<td class="hdlist1">
 
1232
Direction
 
1233
<br />
 
1234
</td>
 
1235
<td class="hdlist2">
 
1236
<p style="margin-top: 0;">
 
1237
Unidirectional
 
1238
</p>
 
1239
</td>
 
1240
</tr>
 
1241
<tr>
 
1242
<td class="hdlist1">
1110
1243
Send/receive pattern
1111
1244
<br />
1112
1245
</td>
1157
1290
<div class="paragraph"><p>The pipeline pattern is used for distributing data to <em>nodes</em> arranged in
1158
1291
a pipeline. Data always flows down the pipeline, and each stage of the pipeline
1159
1292
is connected to at least one <em>node</em>. When a pipeline stage is connected to
1160
 
multiple <em>nodes</em> data is load-balanced among all connected <em>nodes</em>.</p></div>
 
1293
multiple <em>nodes</em> data is round-robined among all connected <em>nodes</em>.</p></div>
1161
1294
<div class="sect3">
1162
1295
<h4 id="_zmq_push">ZMQ_PUSH</h4>
1163
1296
<div class="paragraph"><p>A socket of type <em>ZMQ_PUSH</em> is used by a pipeline <em>node</em> to send messages
1164
 
to downstream pipeline <em>nodes</em>. Messages are load-balanced to all connected
 
1297
to downstream pipeline <em>nodes</em>. Messages are round-robined to all connected
1165
1298
downstream <em>nodes</em>. The <em>zmq_recv()</em> function is not implemented for this
1166
1299
socket type.</p></div>
1167
1300
<div class="paragraph"><p>When a <em>ZMQ_PUSH</em> socket enters an exceptional state due to having reached the
1221
1354
</td>
1222
1355
<td class="hdlist2">
1223
1356
<p style="margin-top: 0;">
1224
 
Load-balanced
 
1357
Round-robin
1225
1358
</p>
1226
1359
</td>
1227
1360
</tr>
1316
1449
</div>
1317
1450
<div class="sect2">
1318
1451
<h3 id="_exclusive_pair_pattern">Exclusive pair pattern</h3>
1319
 
<div class="paragraph"><p>The exclusive pair is an advanced pattern used for communicating exclusively
1320
 
between two peers.</p></div>
 
1452
<div class="paragraph"><p>The exclusive pair pattern is used to connect a peer to precisely one other
 
1453
peer. This pattern is used for inter-thread communication across the inproc
 
1454
transport.</p></div>
1321
1455
<div class="sect3">
1322
1456
<h4 id="_zmq_pair">ZMQ_PAIR</h4>
1323
1457
<div class="paragraph"><p>A socket of type <em>ZMQ_PAIR</em> can only be connected to a single peer at any one
1332
1466
<td class="icon">
1333
1467
<div class="title">Note</div>
1334
1468
</td>
1335
 
<td class="content"><em>ZMQ_PAIR</em> sockets are experimental, and are currently missing several
1336
 
features such as auto-reconnection.</td>
 
1469
<td class="content"><em>ZMQ_PAIR</em> sockets are designed for inter-thread communication across
 
1470
the <a href="zmq_inproc.html">zmq_inproc(7)</a> transport and do not implement functionality such
 
1471
as auto-reconnection. <em>ZMQ_PAIR</em> sockets are considered experimental and may
 
1472
have other missing or broken aspects.</td>
1337
1473
</tr></table>
1338
1474
</div>
1339
1475
<div class="hdlist"><div class="title">Summary of ZMQ_PAIR characteristics</div><table>
1464
1600
<a href="zmq_connect.html">zmq_connect(3)</a>
1465
1601
<a href="zmq_send.html">zmq_send(3)</a>
1466
1602
<a href="zmq_recv.html">zmq_recv(3)</a>
 
1603
<a href="zmq_inproc.html">zmq_inproc(7)</a>
1467
1604
<a href="zmq.html">zmq(7)</a></p></div>
1468
1605
</div>
1469
1606
</div>
1470
1607
<div class="sect1">
1471
1608
<h2 id="_authors">AUTHORS</h2>
1472
1609
<div class="sectionbody">
1473
 
<div class="paragraph"><p>The ØMQ documentation was written by Martin Sustrik &lt;<a href="mailto:sustrik@250bpm.com">sustrik@250bpm.com</a>&gt; and
1474
 
Martin Lucina &lt;<a href="mailto:martin@lucina.net">martin@lucina.net</a>&gt;.</p></div>
 
1610
<div class="paragraph"><p>This ØMQ manual page was written by Martin Sustrik &lt;<a href="mailto:sustrik@250bpm.com">sustrik@250bpm.com</a>&gt;,
 
1611
Martin Lucina &lt;<a href="mailto:mato@kotelna.sk">mato@kotelna.sk</a>&gt;, and Pieter Hintjens &lt;<a href="mailto:ph@imatix.com">ph@imatix.com</a>&gt;.</p></div>
1475
1612
</div>
1476
1613
</div>
1477
1614
</div>
1478
1615
<div id="footnotes"><hr /></div>
1479
1616
<div id="footer">
1480
1617
<div id="footer-text">
1481
 
ØMQ 3.1.0<br />
1482
 
Last updated 2011-12-18 11:17:56 CET
 
1618
ØMQ 3.2.0<br />
 
1619
Last updated 2012-06-05 09:39:30 CEST
1483
1620
</div>
1484
1621
</div>
1485
1622
</body>