Ejemplo n.º 1
0
static zyre_node_t *
zyre_node_new (zsock_t *pipe, void *args)
{
    zyre_node_t *self = (zyre_node_t *) zmalloc (sizeof (zyre_node_t));
    self->inbox = zsock_new (ZMQ_ROUTER);
    if (self->inbox == NULL) {
        free (self);
        return NULL;            //  Could not create new socket
    }
    //  Use ZMQ_ROUTER_HANDOVER so that when a peer disconnects and
    //  then reconnects, the new client connection is treated as the
    //  canonical one, and any old trailing commands are discarded.
    zsock_set_router_handover (self->inbox, 1);
    
    self->pipe = pipe;
    self->outbox = (zsock_t *) args;
    self->poller = zpoller_new (self->pipe, NULL);
    self->beacon_port = ZRE_DISCOVERY_PORT;
    self->interval = 0;         //  Use default
    self->uuid = zuuid_new ();
    self->peers = zhash_new ();
    self->peer_groups = zhash_new ();
    self->own_groups = zhash_new ();
    self->headers = zhash_new ();
    zhash_autofree (self->headers);

    //  Default name for node is first 6 characters of UUID:
    //  the shorter string is more readable in logs
    self->name = (char *) zmalloc (7);
    memcpy (self->name, zuuid_str (self->uuid), 6);
    return self;
}
Ejemplo n.º 2
0
///
//  Set socket option `router_handover`.
void QZsock::setRouterHandover (int routerHandover)
{
    zsock_set_router_handover (self, routerHandover);
    
}
Ejemplo n.º 3
0
JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setRouterHandover (JNIEnv *env, jclass c, jlong self, jint router_handover)
{
    zsock_set_router_handover ((zsock_t *) (intptr_t) self, (int) router_handover);
}