1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
6
<meta name="generator" content="AsciiDoc 8.6.3" />
7
<title>zmq_poll(3)</title>
8
<style type="text/css">
10
h1, h2, h3, h4, h5, h6,
11
div.title, caption.title,
12
thead, p.table.header,
14
span#author, span#revnumber, span#revdate, span#revremark,
16
font-family: Arial,Helvetica,sans-serif;
21
font-family: Georgia,"Times New Roman",Times,serif;
30
margin: 1em 5% 1em 5%;
35
text-decoration: underline;
56
h1, h2, h3, h4, h5, h6 {
64
border-bottom: 2px solid silver;
81
border: 1px solid silver;
92
ul > li { color: #aaa; }
93
ul > li > * { color: black; }
107
span#revnumber, span#revdate, span#revremark {
112
border-top: 2px solid silver;
118
padding-bottom: 0.5em;
122
padding-bottom: 0.5em;
127
margin-bottom: 1.5em;
129
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
130
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
131
div.admonitionblock {
133
margin-bottom: 1.5em;
135
div.admonitionblock {
137
margin-bottom: 2.0em;
142
div.content { /* Block element content. */
146
/* Block element titles. */
147
div.title, caption.title {
152
margin-bottom: 0.5em;
158
td div.title:first-child {
161
div.content div.title:first-child {
164
div.content + div.title {
168
div.sidebarblock > div.content {
170
border: 1px solid #dddddd;
171
border-left: 4px solid #f0f0f0;
175
div.listingblock > div.content {
176
border: 1px solid #dddddd;
177
border-left: 5px solid #f0f0f0;
182
div.quoteblock, div.verseblock {
186
border-left: 5px solid #f0f0f0;
190
div.quoteblock > div.attribution {
195
div.verseblock > pre.content {
196
font-family: inherit;
199
div.verseblock > div.attribution {
203
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
204
div.verseblock + div.attribution {
208
div.admonitionblock .icon {
212
text-decoration: underline;
214
padding-right: 0.5em;
216
div.admonitionblock td.content {
218
border-left: 3px solid #dddddd;
221
div.exampleblock > div.content {
222
border-left: 3px solid #dddddd;
226
div.imageblock div.content { padding-left: 0; }
227
span.image img { border-style: none; }
228
a.image:visited { color: white; }
232
margin-bottom: 0.8em;
245
list-style-position: outside;
248
list-style-type: decimal;
251
list-style-type: lower-alpha;
254
list-style-type: upper-alpha;
257
list-style-type: lower-roman;
260
list-style-type: upper-roman;
263
div.compact ul, div.compact ol,
264
div.compact p, div.compact p,
265
div.compact div, div.compact div {
267
margin-bottom: 0.1em;
270
div.tableblock > table {
271
border: 3px solid #527bbd;
273
thead, p.table.header {
286
/* Because the table frame attribute is overriden by CSS in most browsers. */
287
div.tableblock > table[frame="void"] {
290
div.tableblock > table[frame="hsides"] {
291
border-left-style: none;
292
border-right-style: none;
294
div.tableblock > table[frame="vsides"] {
295
border-top-style: none;
296
border-bottom-style: none;
302
margin-bottom: 0.8em;
305
padding-bottom: 15px;
307
dt.hdlist1.strong, td.hdlist1.strong {
313
padding-right: 0.8em;
319
div.hdlist.compact tr {
328
.footnote, .footnoteref {
332
span.footnote, span.footnoteref {
333
vertical-align: super;
337
margin: 20px 0 20px 0;
341
#footnotes div.footnote {
347
border-top: 1px solid silver;
356
padding-right: 0.5em;
357
padding-bottom: 0.3em;
365
div#footer-badges { display: none; }
369
margin-bottom: 2.5em;
377
margin-bottom: 0.1em;
380
div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
397
/* Overrides for manpage documents */
400
padding-bottom: 0.5em;
401
border-top: 2px solid silver;
402
border-bottom: 2px solid silver;
412
div#toc { display: none; }
416
<script type="text/javascript">
418
window.onload = function(){asciidoc.footnotes();}
419
var asciidoc = { // Namespace.
421
/////////////////////////////////////////////////////////////////////
422
// Table Of Contents generator
423
/////////////////////////////////////////////////////////////////////
425
/* Author: Mihai Bazon, September 2002
426
* http://students.infoiasi.ro/~mishoo
428
* Table Of Content generator
431
* Feel free to use this script under the terms of the GNU General Public
432
* License, as long as you do not remove or alter this notice.
435
/* modified by Troy D. Hanson, September 2006. License: GPL */
436
/* modified by Stuart Rackham, 2006, 2009. License: GPL */
439
toc: function (toclevels) {
441
function getText(el) {
443
for (var i = el.firstChild; i != null; i = i.nextSibling) {
444
if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
446
else if (i.firstChild != null)
452
function TocEntry(el, text, toclevel) {
455
this.toclevel = toclevel;
458
function tocEntries(el, toclevels) {
459
var result = new Array;
460
var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
461
// Function that scans the DOM tree for header elements (the DOM2
462
// nodeIterator API would be a better technique but not supported by all
464
var iterate = function (el) {
465
for (var i = el.firstChild; i != null; i = i.nextSibling) {
466
if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
467
var mo = re.exec(i.tagName);
468
if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
469
result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
479
var toc = document.getElementById("toc");
480
var entries = tocEntries(document.getElementById("content"), toclevels);
481
for (var i = 0; i < entries.length; ++i) {
482
var entry = entries[i];
483
if (entry.element.id == "")
484
entry.element.id = "_toc_" + i;
485
var a = document.createElement("a");
486
a.href = "#" + entry.element.id;
487
a.appendChild(document.createTextNode(entry.text));
488
var div = document.createElement("div");
490
div.className = "toclevel" + entry.toclevel;
491
toc.appendChild(div);
493
if (entries.length == 0)
494
toc.parentNode.removeChild(toc);
498
/////////////////////////////////////////////////////////////////////
499
// Footnotes generator
500
/////////////////////////////////////////////////////////////////////
502
/* Based on footnote generation code from:
503
* http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
506
footnotes: function () {
507
var cont = document.getElementById("content");
508
var noteholder = document.getElementById("footnotes");
509
var spans = cont.getElementsByTagName("span");
512
for (i=0; i<spans.length; i++) {
513
if (spans[i].className == "footnote") {
515
// Use [\s\S] in place of . so multi-line matches work.
516
// Because JavaScript has no s (dotall) regex flag.
517
note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
518
noteholder.innerHTML +=
519
"<div class='footnote' id='_footnote_" + n + "'>" +
520
"<a href='#_footnoteref_" + n + "' title='Return to text'>" +
521
n + "</a>. " + note + "</div>";
523
"[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
524
"' title='View footnote' class='footnote'>" + n + "</a>]";
525
var id =spans[i].getAttribute("id");
526
if (id != null) refs["#"+id] = n;
530
noteholder.parentNode.removeChild(noteholder);
532
// Process footnoterefs.
533
for (i=0; i<spans.length; i++) {
534
if (spans[i].className == "footnoteref") {
535
var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
536
href = href.match(/#.*/)[0]; // Because IE return full URL.
539
"[<a href='#_footnote_" + n +
540
"' title='View footnote' class='footnote'>" + n + "</a>]";
550
<body class="manpage">
553
zmq_poll(3) Manual Page
556
<div class="sectionbody">
558
input/output multiplexing
564
<h2 id="_synopsis">SYNOPSIS</h2>
565
<div class="sectionbody">
566
<div class="paragraph"><p><strong>int zmq_poll (zmq_pollitem_t <em>*items</em>, int <em>nitems</em>, long <em>timeout</em>);</strong></p></div>
570
<h2 id="_description">DESCRIPTION</h2>
571
<div class="sectionbody">
572
<div class="paragraph"><p>The <em>zmq_poll()</em> function provides a mechanism for applications to multiplex
573
input/output events in a level-triggered fashion over a set of sockets. Each
574
member of the array pointed to by the <em>items</em> argument is a <strong>zmq_pollitem_t</strong>
575
structure. The <em>nitems</em> argument specifies the number of items in the <em>items</em>
576
array. The <strong>zmq_pollitem_t</strong> structure is defined as follows:</p></div>
577
<div class="literalblock">
578
<div class="content">
579
<pre><tt>typedef struct
581
void <em>*socket</em>;
583
short <em>events</em>;
584
short <em>revents</em>;
585
} zmq_pollitem_t;</tt></pre>
587
<div class="paragraph"><p>For each <strong>zmq_pollitem_t</strong> item, <em>zmq_poll()</em> shall examine either the ØMQ
588
socket referenced by <em>socket</em> <strong>or</strong> the standard socket specified by the file
589
descriptor <em>fd</em>, for the event(s) specified in <em>events</em>. If both <em>socket</em> and
590
<em>fd</em> are set in a single <strong>zmq_pollitem_t</strong>, the ØMQ socket referenced by
591
<em>socket</em> shall take precedence and the value of <em>fd</em> shall be ignored.</p></div>
592
<div class="paragraph"><p>For each <strong>zmq_pollitem_t</strong> item, <em>zmq_poll()</em> shall first clear the <em>revents</em>
593
member, and then indicate any requested events that have occurred by setting the
594
bit corresponding to the event condition in the <em>revents</em> member.</p></div>
595
<div class="paragraph"><p>If none of the requested events have occurred on any <strong>zmq_pollitem_t</strong> item,
596
<em>zmq_poll()</em> shall wait <em>timeout</em> milliseconds for an event to occur on
597
any of the requested items. If the value of <em>timeout</em> is <tt>0</tt>, <em>zmq_poll()</em>
598
shall return immediately. If the value of <em>timeout</em> is <tt>-1</tt>, <em>zmq_poll()</em> shall
599
block indefinitely until a requested event has occurred on at least one
600
<strong>zmq_pollitem_t</strong>.</p></div>
601
<div class="paragraph"><p>The <em>events</em> and <em>revents</em> members of <strong>zmq_pollitem_t</strong> are bit masks constructed
602
by OR’ing a combination of the following event flags:</p></div>
603
<div class="dlist"><dl>
605
<strong>ZMQ_POLLIN</strong>
609
For ØMQ sockets, at least one message may be received from the <em>socket</em> without
610
blocking. For standard sockets this is equivalent to the <em>POLLIN</em> flag of the
611
<em>poll()</em> system call and generally means that at least one byte of data may be
612
read from <em>fd</em> without blocking.
616
<strong>ZMQ_POLLOUT</strong>
620
For ØMQ sockets, at least one message may be sent to the <em>socket</em> without
621
blocking. For standard sockets this is equivalent to the <em>POLLOUT</em> flag of the
622
<em>poll()</em> system call and generally means that at least one byte of data may be
623
written to <em>fd</em> without blocking.
627
<strong>ZMQ_POLLERR</strong>
631
For standard sockets, this flag is passed through <em>zmq_poll()</em> to the
632
underlying <em>poll()</em> system call and generally means that some sort of error
633
condition is present on the socket specified by <em>fd</em>. For ØMQ sockets this flag
634
has no effect if set in <em>events</em>, and shall never be returned in <em>revents</em> by
639
<div class="admonitionblock">
642
<div class="title">Note</div>
644
<td class="content">The <em>zmq_poll()</em> function may be implemented or emulated using operating
645
system interfaces other than <em>poll()</em>, and as such may be subject to the limits
646
of those interfaces in ways not defined in this documentation.</td>
652
<h2 id="_return_value">RETURN VALUE</h2>
653
<div class="sectionbody">
654
<div class="paragraph"><p>Upon successful completion, the <em>zmq_poll()</em> function shall return the number
655
of <strong>zmq_pollitem_t</strong> structures with events signaled in <em>revents</em> or <tt>0</tt> if no
656
events have been signaled. Upon failure, <em>zmq_poll()</em> shall return <tt>-1</tt> and set
657
<em>errno</em> to one of the values defined below.</p></div>
661
<h2 id="_errors">ERRORS</h2>
662
<div class="sectionbody">
663
<div class="dlist"><dl>
665
<strong>ETERM</strong>
669
At least one of the members of the <em>items</em> array refers to a <em>socket</em> whose
670
associated ØMQ <em>context</em> was terminated.
674
<strong>EFAULT</strong>
678
The provided <em>items</em> was not valid (NULL).
682
<strong>EINTR</strong>
686
The operation was interrupted by delivery of a signal before any events were
694
<h2 id="_example">EXAMPLE</h2>
695
<div class="sectionbody">
696
<div class="listingblock">
697
<div class="title">Polling indefinitely for input events on both a ØMQ socket and a standard socket.</div>
698
<div class="content">
699
<pre><tt>zmq_pollitem_t items [2];
700
/* First item refers to 0MQ socket 'socket' */
701
items[0].socket = socket;
702
items[0].events = ZMQ_POLLIN;
703
/* Second item refers to standard socket 'fd' */
704
items[1].socket = NULL;
706
items[1].events = ZMQ_POLLIN;
707
/* Poll for events indefinitely */
708
int rc = zmq_poll (items, 2, -1);
710
/* Returned events will be stored in items[].revents */</tt></pre>
715
<h2 id="_see_also">SEE ALSO</h2>
716
<div class="sectionbody">
717
<div class="paragraph"><p><a href="zmq_socket.html">zmq_socket(3)</a>
718
<a href="zmq_send.html">zmq_send(3)</a>
719
<a href="zmq_recv.html">zmq_recv(3)</a>
720
<a href="zmq.html">zmq(7)</a></p></div>
721
<div class="paragraph"><p>Your operating system documentation for the <em>poll()</em> system call.</p></div>
725
<h2 id="_authors">AUTHORS</h2>
726
<div class="sectionbody">
727
<div class="paragraph"><p>The ØMQ documentation was written by Martin Sustrik <<a href="mailto:sustrik@250bpm.com">sustrik@250bpm.com</a>> and
728
Martin Lucina <<a href="mailto:martin@lucina.net">martin@lucina.net</a>>.</p></div>
732
<div id="footnotes"><hr /></div>
734
<div id="footer-text">
736
Last updated 2011-12-18 11:17:56 CET