~ubuntu-branches/ubuntu/saucy/zeromq3/saucy

« back to all changes in this revision

Viewing changes to doc/zmq_ctx_set_monitor.html

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-10-16 19:49:30 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20121016194930-98r0bi746eoaa4iv
Tags: 3.2.1~rc2+dfsg-1
* New upstream RC release (Closes: #690704)
* Bump Standards-Version to 3.9.4 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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">
4
 
<head>
5
 
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
6
 
<meta name="generator" content="AsciiDoc 8.6.4" />
7
 
<title>zmq_ctx_set_monitor(3)</title>
8
 
<style type="text/css">
9
 
/* Sans-serif font. */
10
 
h1, h2, h3, h4, h5, h6,
11
 
div.title, caption.title,
12
 
thead, p.table.header,
13
 
div#toctitle,
14
 
span#author, span#revnumber, span#revdate, span#revremark,
15
 
div#footer {
16
 
  font-family: Arial,Helvetica,sans-serif;
17
 
}
18
 
 
19
 
/* Serif font. */
20
 
div.sectionbody {
21
 
  font-family: Georgia,"Times New Roman",Times,serif;
22
 
}
23
 
 
24
 
/* Monospace font. */
25
 
tt {
26
 
  font-size: inherit;
27
 
}
28
 
 
29
 
body {
30
 
  margin: 1em 5% 1em 5%;
31
 
}
32
 
 
33
 
a {
34
 
  color: blue;
35
 
  text-decoration: underline;
36
 
}
37
 
a:visited {
38
 
  color: fuchsia;
39
 
}
40
 
 
41
 
em {
42
 
  font-style: italic;
43
 
  color: navy;
44
 
}
45
 
 
46
 
strong {
47
 
  font-weight: bold;
48
 
  color: #083194;
49
 
}
50
 
 
51
 
tt {
52
 
  font-size: inherit;
53
 
  color: navy;
54
 
}
55
 
 
56
 
h1, h2, h3, h4, h5, h6 {
57
 
  color: #527bbd;
58
 
  margin-top: 1.2em;
59
 
  margin-bottom: 0.5em;
60
 
  line-height: 1.3;
61
 
}
62
 
 
63
 
h1, h2, h3 {
64
 
  border-bottom: 2px solid silver;
65
 
}
66
 
h2 {
67
 
  padding-top: 0.5em;
68
 
}
69
 
h3 {
70
 
  float: left;
71
 
}
72
 
h3 + * {
73
 
  clear: left;
74
 
}
75
 
 
76
 
div.sectionbody {
77
 
  margin-left: 0;
78
 
}
79
 
 
80
 
hr {
81
 
  border: 1px solid silver;
82
 
}
83
 
 
84
 
p {
85
 
  margin-top: 0.5em;
86
 
  margin-bottom: 0.5em;
87
 
}
88
 
 
89
 
ul, ol, li > p {
90
 
  margin-top: 0;
91
 
}
92
 
ul > li     { color: #aaa; }
93
 
ul > li > * { color: black; }
94
 
 
95
 
pre {
96
 
  padding: 0;
97
 
  margin: 0;
98
 
}
99
 
 
100
 
span#author {
101
 
  color: #527bbd;
102
 
  font-weight: bold;
103
 
  font-size: 1.1em;
104
 
}
105
 
span#email {
106
 
}
107
 
span#revnumber, span#revdate, span#revremark {
108
 
}
109
 
 
110
 
div#footer {
111
 
  font-size: small;
112
 
  border-top: 2px solid silver;
113
 
  padding-top: 0.5em;
114
 
  margin-top: 4.0em;
115
 
}
116
 
div#footer-text {
117
 
  float: left;
118
 
  padding-bottom: 0.5em;
119
 
}
120
 
div#footer-badges {
121
 
  float: right;
122
 
  padding-bottom: 0.5em;
123
 
}
124
 
 
125
 
div#preamble {
126
 
  margin-top: 1.5em;
127
 
  margin-bottom: 1.5em;
128
 
}
129
 
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
130
 
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
131
 
div.admonitionblock {
132
 
  margin-top: 1.0em;
133
 
  margin-bottom: 1.5em;
134
 
}
135
 
div.admonitionblock {
136
 
  margin-top: 2.0em;
137
 
  margin-bottom: 2.0em;
138
 
  margin-right: 10%;
139
 
  color: #606060;
140
 
}
141
 
 
142
 
div.content { /* Block element content. */
143
 
  padding: 0;
144
 
}
145
 
 
146
 
/* Block element titles. */
147
 
div.title, caption.title {
148
 
  color: #527bbd;
149
 
  font-weight: bold;
150
 
  text-align: left;
151
 
  margin-top: 1.0em;
152
 
  margin-bottom: 0.5em;
153
 
}
154
 
div.title + * {
155
 
  margin-top: 0;
156
 
}
157
 
 
158
 
td div.title:first-child {
159
 
  margin-top: 0.0em;
160
 
}
161
 
div.content div.title:first-child {
162
 
  margin-top: 0.0em;
163
 
}
164
 
div.content + div.title {
165
 
  margin-top: 0.0em;
166
 
}
167
 
 
168
 
div.sidebarblock > div.content {
169
 
  background: #ffffee;
170
 
  border: 1px solid #dddddd;
171
 
  border-left: 4px solid #f0f0f0;
172
 
  padding: 0.5em;
173
 
}
174
 
 
175
 
div.listingblock > div.content {
176
 
  border: 1px solid #dddddd;
177
 
  border-left: 5px solid #f0f0f0;
178
 
  background: #f8f8f8;
179
 
  padding: 0.5em;
180
 
}
181
 
 
182
 
div.quoteblock, div.verseblock {
183
 
  padding-left: 1.0em;
184
 
  margin-left: 1.0em;
185
 
  margin-right: 10%;
186
 
  border-left: 5px solid #f0f0f0;
187
 
  color: #777777;
188
 
}
189
 
 
190
 
div.quoteblock > div.attribution {
191
 
  padding-top: 0.5em;
192
 
  text-align: right;
193
 
}
194
 
 
195
 
div.verseblock > pre.content {
196
 
  font-family: inherit;
197
 
  font-size: inherit;
198
 
}
199
 
div.verseblock > div.attribution {
200
 
  padding-top: 0.75em;
201
 
  text-align: left;
202
 
}
203
 
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
204
 
div.verseblock + div.attribution {
205
 
  text-align: left;
206
 
}
207
 
 
208
 
div.admonitionblock .icon {
209
 
  vertical-align: top;
210
 
  font-size: 1.1em;
211
 
  font-weight: bold;
212
 
  text-decoration: underline;
213
 
  color: #527bbd;
214
 
  padding-right: 0.5em;
215
 
}
216
 
div.admonitionblock td.content {
217
 
  padding-left: 0.5em;
218
 
  border-left: 3px solid #dddddd;
219
 
}
220
 
 
221
 
div.exampleblock > div.content {
222
 
  border-left: 3px solid #dddddd;
223
 
  padding-left: 0.5em;
224
 
}
225
 
 
226
 
div.imageblock div.content { padding-left: 0; }
227
 
span.image img { border-style: none; }
228
 
a.image:visited { color: white; }
229
 
 
230
 
dl {
231
 
  margin-top: 0.8em;
232
 
  margin-bottom: 0.8em;
233
 
}
234
 
dt {
235
 
  margin-top: 0.5em;
236
 
  margin-bottom: 0;
237
 
  font-style: normal;
238
 
  color: navy;
239
 
}
240
 
dd > *:first-child {
241
 
  margin-top: 0.1em;
242
 
}
243
 
 
244
 
ul, ol {
245
 
    list-style-position: outside;
246
 
}
247
 
ol.arabic {
248
 
  list-style-type: decimal;
249
 
}
250
 
ol.loweralpha {
251
 
  list-style-type: lower-alpha;
252
 
}
253
 
ol.upperalpha {
254
 
  list-style-type: upper-alpha;
255
 
}
256
 
ol.lowerroman {
257
 
  list-style-type: lower-roman;
258
 
}
259
 
ol.upperroman {
260
 
  list-style-type: upper-roman;
261
 
}
262
 
 
263
 
div.compact ul, div.compact ol,
264
 
div.compact p, div.compact p,
265
 
div.compact div, div.compact div {
266
 
  margin-top: 0.1em;
267
 
  margin-bottom: 0.1em;
268
 
}
269
 
 
270
 
div.tableblock > table {
271
 
  border: 3px solid #527bbd;
272
 
}
273
 
thead, p.table.header {
274
 
  font-weight: bold;
275
 
  color: #527bbd;
276
 
}
277
 
tfoot {
278
 
  font-weight: bold;
279
 
}
280
 
td > div.verse {
281
 
  white-space: pre;
282
 
}
283
 
p.table {
284
 
  margin-top: 0;
285
 
}
286
 
/* Because the table frame attribute is overriden by CSS in most browsers. */
287
 
div.tableblock > table[frame="void"] {
288
 
  border-style: none;
289
 
}
290
 
div.tableblock > table[frame="hsides"] {
291
 
  border-left-style: none;
292
 
  border-right-style: none;
293
 
}
294
 
div.tableblock > table[frame="vsides"] {
295
 
  border-top-style: none;
296
 
  border-bottom-style: none;
297
 
}
298
 
 
299
 
 
300
 
div.hdlist {
301
 
  margin-top: 0.8em;
302
 
  margin-bottom: 0.8em;
303
 
}
304
 
div.hdlist tr {
305
 
  padding-bottom: 15px;
306
 
}
307
 
dt.hdlist1.strong, td.hdlist1.strong {
308
 
  font-weight: bold;
309
 
}
310
 
td.hdlist1 {
311
 
  vertical-align: top;
312
 
  font-style: normal;
313
 
  padding-right: 0.8em;
314
 
  color: navy;
315
 
}
316
 
td.hdlist2 {
317
 
  vertical-align: top;
318
 
}
319
 
div.hdlist.compact tr {
320
 
  margin: 0;
321
 
  padding-bottom: 0;
322
 
}
323
 
 
324
 
.comment {
325
 
  background: yellow;
326
 
}
327
 
 
328
 
.footnote, .footnoteref {
329
 
  font-size: 0.8em;
330
 
}
331
 
 
332
 
span.footnote, span.footnoteref {
333
 
  vertical-align: super;
334
 
}
335
 
 
336
 
#footnotes {
337
 
  margin: 20px 0 20px 0;
338
 
  padding: 7px 0 0 0;
339
 
}
340
 
 
341
 
#footnotes div.footnote {
342
 
  margin: 0 0 5px 0;
343
 
}
344
 
 
345
 
#footnotes hr {
346
 
  border: none;
347
 
  border-top: 1px solid silver;
348
 
  height: 1px;
349
 
  text-align: left;
350
 
  margin-left: 0;
351
 
  width: 20%;
352
 
  min-width: 100px;
353
 
}
354
 
 
355
 
div.colist td {
356
 
  padding-right: 0.5em;
357
 
  padding-bottom: 0.3em;
358
 
  vertical-align: top;
359
 
}
360
 
div.colist td img {
361
 
  margin-top: 0.3em;
362
 
}
363
 
 
364
 
@media print {
365
 
  div#footer-badges { display: none; }
366
 
}
367
 
 
368
 
div#toc {
369
 
  margin-bottom: 2.5em;
370
 
}
371
 
 
372
 
div#toctitle {
373
 
  color: #527bbd;
374
 
  font-size: 1.1em;
375
 
  font-weight: bold;
376
 
  margin-top: 1.0em;
377
 
  margin-bottom: 0.1em;
378
 
}
379
 
 
380
 
div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
381
 
  margin-top: 0;
382
 
  margin-bottom: 0;
383
 
}
384
 
div.toclevel2 {
385
 
  margin-left: 2em;
386
 
  font-size: 0.9em;
387
 
}
388
 
div.toclevel3 {
389
 
  margin-left: 4em;
390
 
  font-size: 0.9em;
391
 
}
392
 
div.toclevel4 {
393
 
  margin-left: 6em;
394
 
  font-size: 0.9em;
395
 
}
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; }
433
 
/* Overrides for manpage documents */
434
 
h1 {
435
 
  padding-top: 0.5em;
436
 
  padding-bottom: 0.5em;
437
 
  border-top: 2px solid silver;
438
 
  border-bottom: 2px solid silver;
439
 
}
440
 
h2 {
441
 
  border-style: none;
442
 
}
443
 
div.sectionbody {
444
 
  margin-left: 5%;
445
 
}
446
 
 
447
 
@media print {
448
 
  div#toc { display: none; }
449
 
}
450
 
 
451
 
</style>
452
 
<script type="text/javascript">
453
 
/*<![CDATA[*/
454
 
window.onload = function(){asciidoc.footnotes();}
455
 
var asciidoc = {  // Namespace.
456
 
 
457
 
/////////////////////////////////////////////////////////////////////
458
 
// Table Of Contents generator
459
 
/////////////////////////////////////////////////////////////////////
460
 
 
461
 
/* Author: Mihai Bazon, September 2002
462
 
 * http://students.infoiasi.ro/~mishoo
463
 
 *
464
 
 * Table Of Content generator
465
 
 * Version: 0.4
466
 
 *
467
 
 * Feel free to use this script under the terms of the GNU General Public
468
 
 * License, as long as you do not remove or alter this notice.
469
 
 */
470
 
 
471
 
 /* modified by Troy D. Hanson, September 2006. License: GPL */
472
 
 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
473
 
 
474
 
// toclevels = 1..4.
475
 
toc: function (toclevels) {
476
 
 
477
 
  function getText(el) {
478
 
    var text = "";
479
 
    for (var i = el.firstChild; i != null; i = i.nextSibling) {
480
 
      if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
481
 
        text += i.data;
482
 
      else if (i.firstChild != null)
483
 
        text += getText(i);
484
 
    }
485
 
    return text;
486
 
  }
487
 
 
488
 
  function TocEntry(el, text, toclevel) {
489
 
    this.element = el;
490
 
    this.text = text;
491
 
    this.toclevel = toclevel;
492
 
  }
493
 
 
494
 
  function tocEntries(el, toclevels) {
495
 
    var result = new Array;
496
 
    var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
497
 
    // Function that scans the DOM tree for header elements (the DOM2
498
 
    // nodeIterator API would be a better technique but not supported by all
499
 
    // browsers).
500
 
    var iterate = function (el) {
501
 
      for (var i = el.firstChild; i != null; i = i.nextSibling) {
502
 
        if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
503
 
          var mo = re.exec(i.tagName);
504
 
          if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
505
 
            result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
506
 
          }
507
 
          iterate(i);
508
 
        }
509
 
      }
510
 
    }
511
 
    iterate(el);
512
 
    return result;
513
 
  }
514
 
 
515
 
  var toc = document.getElementById("toc");
516
 
  var entries = tocEntries(document.getElementById("content"), toclevels);
517
 
  for (var i = 0; i < entries.length; ++i) {
518
 
    var entry = entries[i];
519
 
    if (entry.element.id == "")
520
 
      entry.element.id = "_toc_" + i;
521
 
    var a = document.createElement("a");
522
 
    a.href = "#" + entry.element.id;
523
 
    a.appendChild(document.createTextNode(entry.text));
524
 
    var div = document.createElement("div");
525
 
    div.appendChild(a);
526
 
    div.className = "toclevel" + entry.toclevel;
527
 
    toc.appendChild(div);
528
 
  }
529
 
  if (entries.length == 0)
530
 
    toc.parentNode.removeChild(toc);
531
 
},
532
 
 
533
 
 
534
 
/////////////////////////////////////////////////////////////////////
535
 
// Footnotes generator
536
 
/////////////////////////////////////////////////////////////////////
537
 
 
538
 
/* Based on footnote generation code from:
539
 
 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
540
 
 */
541
 
 
542
 
footnotes: function () {
543
 
  var cont = document.getElementById("content");
544
 
  var noteholder = document.getElementById("footnotes");
545
 
  var spans = cont.getElementsByTagName("span");
546
 
  var refs = {};
547
 
  var n = 0;
548
 
  for (i=0; i<spans.length; i++) {
549
 
    if (spans[i].className == "footnote") {
550
 
      n++;
551
 
      // Use [\s\S] in place of . so multi-line matches work.
552
 
      // Because JavaScript has no s (dotall) regex flag.
553
 
      note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
554
 
      noteholder.innerHTML +=
555
 
        "<div class='footnote' id='_footnote_" + n + "'>" +
556
 
        "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
557
 
        n + "</a>. " + note + "</div>";
558
 
      spans[i].innerHTML =
559
 
        "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
560
 
        "' title='View footnote' class='footnote'>" + n + "</a>]";
561
 
      var id =spans[i].getAttribute("id");
562
 
      if (id != null) refs["#"+id] = n;
563
 
    }
564
 
  }
565
 
  if (n == 0)
566
 
    noteholder.parentNode.removeChild(noteholder);
567
 
  else {
568
 
    // Process footnoterefs.
569
 
    for (i=0; i<spans.length; i++) {
570
 
      if (spans[i].className == "footnoteref") {
571
 
        var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
572
 
        href = href.match(/#.*/)[0];  // Because IE return full URL.
573
 
        n = refs[href];
574
 
        spans[i].innerHTML =
575
 
          "[<a href='#_footnote_" + n +
576
 
          "' title='View footnote' class='footnote'>" + n + "</a>]";
577
 
      }
578
 
    }
579
 
  }
580
 
}
581
 
 
582
 
}
583
 
/*]]>*/
584
 
</script>
585
 
</head>
586
 
<body class="manpage">
587
 
<div id="header">
588
 
<h1>
589
 
zmq_ctx_set_monitor(3) Manual Page
590
 
</h1>
591
 
<h2>NAME</h2>
592
 
<div class="sectionbody">
593
 
<p>zmq_ctx_set_monitor -
594
 
   register a monitoring callback
595
 
</p>
596
 
</div>
597
 
</div>
598
 
<div id="content">
599
 
<div class="sect1">
600
 
<h2 id="_synopsis">SYNOPSIS</h2>
601
 
<div class="sectionbody">
602
 
<div class="paragraph"><p><strong>int zmq_ctx_set_monitor (void <em>*context</em>, zmq_monitor_fn <em>*monitor</em>);</strong></p></div>
603
 
</div>
604
 
</div>
605
 
<div class="sect1">
606
 
<h2 id="_description">DESCRIPTION</h2>
607
 
<div class="sectionbody">
608
 
<div class="paragraph"><p>The <em>zmq_ctx_set_monitor()</em> function shall register a callback function specified by
609
 
the <em>monitor</em> argument. This is an event sink for changes in per socket
610
 
connection and mailbox (work in progress) states.</p></div>
611
 
<div class="listingblock">
612
 
<div class="title">The <em>zmq_ctx_set_monitor()</em> callback function is expected to have this prototype:</div>
613
 
<div class="content">
614
 
<pre><tt>typedef void (zmq_monitor_fn) (void *s, int event, zmq_event_data_t *data);</tt></pre>
615
 
</div></div>
616
 
<div class="paragraph"><p>The callback is global (per context), with the socket that triggered the event
617
 
passed to the handler as well. Each event also populates a <em>zmq_event_data_t</em>
618
 
union with additional metadata which can be used for correlation.</p></div>
619
 
<div class="admonitionblock">
620
 
<table><tr>
621
 
<td class="icon">
622
 
<div class="title">Caution</div>
623
 
</td>
624
 
<td class="content"><em>zmq_ctx_set_monitor()</em> is intended for monitoring infrastructure / operations
625
 
concerns only - NOT BUSINESS LOGIC. An event is a representation of something
626
 
that happened - you cannot change the past, but only react to them. The
627
 
implementation is also only concerned with a single session. No state of peers,
628
 
other sessions etc. are tracked - this will only pollute internals and is the
629
 
responsibility of application authors to either implement or correlate in
630
 
another datastore. Monitor events are exceptional conditions and are thus not
631
 
directly in the messaging critical path. However, still be careful with what
632
 
you&#8217;re doing in the callback function as excess time spent in the handler will
633
 
block the socket&#8217;s application thread.</td>
634
 
</tr></table>
635
 
</div>
636
 
<div class="paragraph"><p>Only tcp and ipc specific transport events are supported in this initial
637
 
implementation.</p></div>
638
 
<div class="paragraph"><p>Supported events are:</p></div>
639
 
<div class="sect2">
640
 
<h3 id="_zmq_event_connected_connection_established">ZMQ_EVENT_CONNECTED: connection established</h3>
641
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_CONNECTED</em> event triggers when a connection has been established
642
 
to a remote peer. This can happen either synchronous or asynchronous.</p></div>
643
 
<div class="listingblock">
644
 
<div class="title">Callback metadata:</div>
645
 
<div class="content">
646
 
<pre><tt>data.connected.addr // peer address
647
 
data.connected.fd // socket descriptor</tt></pre>
648
 
</div></div>
649
 
</div>
650
 
<div class="sect2">
651
 
<h3 id="_zmq_event_connect_delayed_synchronous_connect_failed_it_8217_s_being_polled">ZMQ_EVENT_CONNECT_DELAYED: synchronous connect failed, it&#8217;s being polled</h3>
652
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_CONNECT_DELAYED</em> event triggers when an immediate connection
653
 
attempt is delayed and it&#8217;s completion&#8217;s being polled for.</p></div>
654
 
<div class="listingblock">
655
 
<div class="title">Callback metadata:</div>
656
 
<div class="content">
657
 
<pre><tt>data.connect_delayed.addr // peer address
658
 
data.connect_delayed.err // errno</tt></pre>
659
 
</div></div>
660
 
</div>
661
 
<div class="sect2">
662
 
<h3 id="_zmq_event_connect_retried_asynchronous_connect_reconnection_attempt">ZMQ_EVENT_CONNECT_RETRIED: asynchronous connect / reconnection attempt</h3>
663
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_CONNECT_RETRIED</em> event triggers when a connection attempt
664
 
is being handled by reconnect timer. The reconnect interval&#8217;s recomputed
665
 
for each attempt.</p></div>
666
 
<div class="listingblock">
667
 
<div class="title">Callback metadata:</div>
668
 
<div class="content">
669
 
<pre><tt>data.connect_retried.addr // peer address
670
 
data.connect_retried.interval // computed reconnect interval</tt></pre>
671
 
</div></div>
672
 
</div>
673
 
<div class="sect2">
674
 
<h3 id="_zmq_event_listening_socket_bound_to_an_address_ready_to_accept_connections">ZMQ_EVENT_LISTENING: socket bound to an address, ready to accept connections</h3>
675
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_LISTENING</em> event triggers when a socket&#8217;s successfully bound
676
 
to a an interface.</p></div>
677
 
<div class="listingblock">
678
 
<div class="title">Callback metadata:</div>
679
 
<div class="content">
680
 
<pre><tt>data.listening.addr //  listen address
681
 
data.listening.fd // socket descriptor</tt></pre>
682
 
</div></div>
683
 
</div>
684
 
<div class="sect2">
685
 
<h3 id="_zmq_event_bind_failed_socket_could_not_bind_to_an_address">ZMQ_EVENT_BIND_FAILED: socket could not bind to an address</h3>
686
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_BIND_FAILED</em> event triggers when a socket could not bind to
687
 
a given interface.</p></div>
688
 
<div class="listingblock">
689
 
<div class="title">Callback metadata:</div>
690
 
<div class="content">
691
 
<pre><tt>data.bind_failed.addr // listen address
692
 
data.bind_failed.err // errno</tt></pre>
693
 
</div></div>
694
 
</div>
695
 
<div class="sect2">
696
 
<h3 id="_zmq_event_accepted_connection_accepted_to_bound_interface">ZMQ_EVENT_ACCEPTED: connection accepted to bound interface</h3>
697
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_ACCEPTED</em> event triggers when a connection from a remote peer
698
 
has been established with a socket&#8217;s listen address.</p></div>
699
 
<div class="listingblock">
700
 
<div class="title">Callback metadata:</div>
701
 
<div class="content">
702
 
<pre><tt>data.accepted.addr // listen address
703
 
data.accepted.fd // socket descriptor</tt></pre>
704
 
</div></div>
705
 
</div>
706
 
<div class="sect2">
707
 
<h3 id="_zmq_event_accept_failed_could_not_accept_client_connection">ZMQ_EVENT_ACCEPT_FAILED: could not accept client connection</h3>
708
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_ACCEPT_FAILED</em> event triggers when a connection attempt to
709
 
a socket&#8217;s bound address fails.</p></div>
710
 
<div class="listingblock">
711
 
<div class="title">Callback metadata:</div>
712
 
<div class="content">
713
 
<pre><tt>data.accept_failed.addr // listen address
714
 
data.accept_failed.err // errno</tt></pre>
715
 
</div></div>
716
 
</div>
717
 
<div class="sect2">
718
 
<h3 id="_zmq_event_closed_connection_closed">ZMQ_EVENT_CLOSED: connection closed</h3>
719
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_CLOSED</em> event triggers when a connection&#8217;s underlying descriptor
720
 
has been closed.</p></div>
721
 
<div class="listingblock">
722
 
<div class="title">Callback metadata:</div>
723
 
<div class="content">
724
 
<pre><tt>data.closed.addr // address
725
 
data.closed.fd // socket descriptor</tt></pre>
726
 
</div></div>
727
 
</div>
728
 
<div class="sect2">
729
 
<h3 id="_zmq_event_close_failed_connection_couldn_8217_t_be_closed">ZMQ_EVENT_CLOSE_FAILED: connection couldn&#8217;t be closed</h3>
730
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_CLOSE_FAILED</em> event triggers when a descriptor could not be
731
 
released back to the OS.</p></div>
732
 
<div class="listingblock">
733
 
<div class="title">Callback metadata:</div>
734
 
<div class="content">
735
 
<pre><tt>data.close_failed.addr // address
736
 
data.close_failed.err // errno</tt></pre>
737
 
</div></div>
738
 
</div>
739
 
<div class="sect2">
740
 
<h3 id="_zmq_event_disconnected_broken_session">ZMQ_EVENT_DISCONNECTED: broken session</h3>
741
 
<div class="paragraph"><p>The <em>ZMQ_EVENT_DISCONNECTED</em> event triggers when the stream engine (tcp and ipc
742
 
specific) detects a corrupted / broken session.</p></div>
743
 
<div class="listingblock">
744
 
<div class="title">Callback metadata:</div>
745
 
<div class="content">
746
 
<pre><tt>data.disconnected.addr // address
747
 
data.disconnected.fd // socket descriptor</tt></pre>
748
 
</div></div>
749
 
</div>
750
 
</div>
751
 
</div>
752
 
<div class="sect1">
753
 
<h2 id="_return_value">RETURN VALUE</h2>
754
 
<div class="sectionbody">
755
 
<div class="paragraph"><p>The <em>zmq_ctx_set_monitor()</em> function returns a value of 0 or greater if successful.
756
 
Otherwise it returns <tt>-1</tt> and sets <em>errno</em> to one of the values defined
757
 
below.</p></div>
758
 
</div>
759
 
</div>
760
 
<div class="sect1">
761
 
<h2 id="_errors">ERRORS</h2>
762
 
<div class="sectionbody">
763
 
<div class="dlist"><dl>
764
 
<dt class="hdlist1">
765
 
<strong>EINVAL</strong>
766
 
</dt>
767
 
<dd>
768
 
<p>
769
 
The requested callback function <em>monitor</em> is invalid.
770
 
</p>
771
 
</dd>
772
 
</dl></div>
773
 
</div>
774
 
</div>
775
 
<div class="sect1">
776
 
<h2 id="_example">EXAMPLE</h2>
777
 
<div class="sectionbody">
778
 
<div class="listingblock">
779
 
<div class="title">Observing a <em>PUB</em> socket&#8217;s connection state</div>
780
 
<div class="content">
781
 
<pre><tt>void socket_monitor (void *s, int event_, zmq_event_data_t *data_)
782
 
{
783
 
    switch (event_) {
784
 
    case ZMQ_EVENT_LISTENING:
785
 
        printf ("Socket bound to %s, socket descriptor is %d\n",
786
 
                 data.listening.addr, data.listening.fd);
787
 
        break;
788
 
    case ZMQ_EVENT_ACCEPTED:
789
 
        printf ("Accepted connection to %s, socket descriptor is %d\n",
790
 
                data.accepted.addr, data.accepted.fd);
791
 
        break;
792
 
    }
793
 
}
794
 
 
795
 
void *context = zmq_ctx_new ();
796
 
int rc = zmq_ctx_set_monitor (context, socket_monitor);
797
 
assert (rc == 0);
798
 
void *pub = zmq_socket (context, ZMQ_PUB);
799
 
assert (pub);
800
 
void *sub = zmq_socket (context, ZMQ_SUB);
801
 
assert (pub);
802
 
rc = zmq_bind (pub, "tcp://127.0.0.1:5560");
803
 
assert (rc == 0);
804
 
rc = zmq_connect (sub, "tcp://127.0.0.1:5560");
805
 
assert (rc == 0);
806
 
 
807
 
// Allow a window for socket events as connect can be async
808
 
zmq_sleep (1);
809
 
 
810
 
rc = zmq_close (pub);
811
 
assert (rc == 0);
812
 
rc = zmq_close (sub);
813
 
assert (rc == 0);
814
 
 
815
 
zmq_term (context);</tt></pre>
816
 
</div></div>
817
 
</div>
818
 
</div>
819
 
<div class="sect1">
820
 
<h2 id="_see_also">SEE ALSO</h2>
821
 
<div class="sectionbody">
822
 
<div class="paragraph"><p><a href="zmq.html">zmq(7)</a></p></div>
823
 
</div>
824
 
</div>
825
 
<div class="sect1">
826
 
<h2 id="_authors">AUTHORS</h2>
827
 
<div class="sectionbody">
828
 
<div class="paragraph"><p>This ØMQ manual page was written by Lourens Naudé &lt;<a href="mailto:lourens@methodmissing.com">lourens@methodmissing.com</a>&gt;</p></div>
829
 
</div>
830
 
</div>
831
 
</div>
832
 
<div id="footnotes"><hr /></div>
833
 
<div id="footer">
834
 
<div id="footer-text">
835
 
ØMQ 3.2.0<br />
836
 
Last updated 2012-06-05 09:39:30 CEST
837
 
</div>
838
 
</div>
839
 
</body>
840
 
</html>