int main (void) { zsys_set_ipv6 (1); zactor_t *root = zactor_new (zgossip, "root"); assert (root); int rc = 0; rc = zstr_sendx (root, "BIND", "tcp://*:5670", NULL); assert (rc == 0); zloop_t *reactor = zloop_new (); assert (reactor); zloop_set_verbose (reactor, true); rc = zloop_reader (reactor, root, handle_pipe, NULL); assert (rc == 0); zloop_start (reactor); zloop_destroy (&reactor); zactor_destroy (&root); return 0; }
int main (int argc, char *argv []) { puts ("glard v1.0.1 -- GL-AR150 demo'n"); // Defaults bool verbose = false; bool console = false; bool ipv6 = false; char *iface = "wlan0"; int argn; for (argn = 1; argn < argc; argn++) { if (streq (argv [argn], "--help") || streq (argv [argn], "-h")) { puts ("glard [options] ..."); puts (" --help / -h this help"); puts (" --verbose / -v verbose test output"); puts (" --interface / -i use this interface"); puts (" --console / -c remote control console"); puts (" --ipv6 / -6 connect over IPv6"); return 0; } if (streq (argv [argn], "--verbose") || streq (argv [argn], "-v")) verbose = true; else if (streq (argv [argn], "--console") || streq (argv [argn], "-c")) console = true; else if (streq (argv [argn], "--interface") || streq (argv [argn], "-i")) iface = argv [++argn]; else if (streq (argv [argn], "--ipv6") || streq (argv [argn], "-6")) ipv6 = true; else { zsys_error ("unknown option: %s\n", argv [argn]); return -1; } } zsys_set_ipv6(ipv6); glar_node_t *node = glar_node_new (iface, console); glar_node_set_verbose (node, verbose); glar_node_execute (node); glar_node_destroy (&node); return 0; }
JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setIpv6 (JNIEnv *env, jclass c, jint ipv6) { zsys_set_ipv6 ((int) ipv6); }
/// // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void QmlZsysAttached::setIpv6 (int ipv6) { zsys_set_ipv6 (ipv6); };
void zsys_test (bool verbose) { printf (" * zsys: "); if (verbose) printf ("\n"); // @selftest zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); free (hostname); zsys_info ("system limit is %zd ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_io_threads (1); zsys_set_max_sockets (0); zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); rc = zsys_file_delete ("nosuchfile"); assert (rc == -1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == -1); time_t when = zsys_file_modified ("."); assert (when > 0); mode_t mode = zsys_file_mode ("."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); zsys_file_mode_private (); rc = zsys_dir_create ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); when = zsys_file_modified ("./.testsys/subdir"); assert (when > 0); assert (!zsys_file_stable ("./.testsys/subdir")); rc = zsys_dir_delete ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", ".", ".testsys"); assert (rc == 0); zsys_file_mode_default (); int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); char *string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); free (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zsocket_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); // @end printf ("OK\n"); }
/// // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void QZsys::setIpv6 (int ipv6) { zsys_set_ipv6 (ipv6); }