GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ZMONITOR (3)

.ds Aq ’

NAME

zmonitor - socket event monitor

CONTENTS

SYNOPSIS

//  Create new zmonitor actor instance to monitor a zsock_t socket:
//
//      zactor_t *monitor = zactor_new (zmonitor, mysocket);
//
//  Destroy zmonitor instance.
//
//      zactor_destroy (&monitor);
//
//  Enable verbose logging of commands and activity.
//
//      zstr_send (monitor, "VERBOSE");
//
//  Listen to monitor event type (zero or types, ending in NULL):
//      zstr_sendx (monitor, "LISTEN", type, ..., NULL);
//
//      Events:
//      CONNECTED
//      CONNECT_DELAYED
//      CONNECT_RETRIED
//      LISTENING
//      BIND_FAILED
//      ACCEPTED
//      ACCEPT_FAILED
//      CLOSED
//      CLOSE_FAILED
//      DISCONNECTED
//      MONITOR_STOPPED
//      ALL
//
//  Start monitor; after this, any further LISTEN commands are ignored.
//
//      zstr_send (monitor, "START");
//      zsock_wait (monitor);
//
//  Receive next monitor event:
//
//      zmsg_t *msg = zmsg_recv (monitor);
//
//  This is the zmonitor constructor as a zactor_fn; the argument can be
//  a zactor_t, zsock_t, or libzmq void * socket:
CZMQ_EXPORT void
    zmonitor (zsock_t *pipe, void *sock);

// Selftest CZMQ_EXPORT void zmonitor_test (bool verbose);

DESCRIPTION

The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints.

This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Works on all versions of libzmq from 3.2 onwards. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock).

EXAMPLE

From zmonitor_test method.

zsock_t *client = zsock_new (ZMQ_DEALER);
assert (client);
zactor_t *clientmon = zactor_new (zmonitor, client);
assert (clientmon);
if (verbose)
    zstr_sendx (clientmon, "VERBOSE", NULL);
zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL);
zstr_sendx (clientmon, "START", NULL);
zsock_wait (clientmon);

zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon);

// Allow a brief time for the message to get there... zmq_poll (NULL, 0, 200);

// Check client is now listening int port_nbr = zsock_bind (client, "tcp://127.0.0.1:*"); assert (port_nbr != -1); s_assert_event (clientmon, "LISTENING");

// Check server connected to client zsock_connect (server, "tcp://127.0.0.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED");

// Check client accepted connection s_assert_event (clientmon, "ACCEPTED");

zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif

AUTHORS

The czmq manual was written by the authors in the AUTHORS file.

RESOURCES

Main web site: \m[blue] \m[]

Report bugs to the email <\m[blue]zeromq-dev@lists.zeromq.org\m[][1]>

COPYRIGHT

Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. LICENSE included with the czmq distribution.

NOTES

1. zeromq-dev@lists.zeromq.org  mailto:zeromq-dev@lists.zeromq.org
Search for    or go to Top of page |  Section 3 |  Main Index


CZMQ 3&.0&.1 ZMONITOR (3) 06/01/2015

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.