当前位置: 首页>>代码示例>>C++>>正文


C++ zsocket_destroy函数代码示例

本文整理汇总了C++中zsocket_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ zsocket_destroy函数的具体用法?C++ zsocket_destroy怎么用?C++ zsocket_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zsocket_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_serial

void read_serial(void * cvoid, zctx_t * context, void * pipe) {
  char * buf;
  serialconfig_t * config = (serialconfig_t*)cvoid;
  
  FILE * in = config->in; // fopen("/dev/ttyO1", "r");

  size_t nbytes=2047;
  //  Prepare our context and publisher
  buf = (char *) malloc(nbytes+1) ;
  fprintf(stderr, "bound\n");
  // first line is always garbage
  getline(&buf, &nbytes, in);
  child_handshake(pipe);
  zsocket_destroy(context, pipe);
  void* socket = zsocket_new(context, ZMQ_PUB);
  zsocket_bind(socket, "inproc://raw_serial");
  
  while ( getline(&buf, &nbytes, in) != -1 ) {
#ifdef DEBUG
    puts("line:");
    puts(buf);

#endif
    zmsg_t * msg = zmsg_new();
    zmsg_pushstr(msg, buf); // does buf need to be copied?
    zmsg_send(&msg, socket);
  }
  fprintf(stderr, "error reading from stdin\n");
  zsocket_destroy(context, socket);
}
开发者ID:sseefried-scratch,项目名称:ninjaduino,代码行数:30,代码来源:serial_relay.c

示例2: s_can_connect

//  Checks whether client can connect to server
static bool
s_can_connect (zctx_t *ctx, void **server, void **client)
{
    int port_nbr = zsocket_bind (*server, "tcp://127.0.0.1:*");
    assert (port_nbr > 0);
    int rc = zsocket_connect (*client, "tcp://127.0.0.1:%d", port_nbr);
    assert (rc == 0);
    //  Give the connection time to fail if that's the plan
    zclock_sleep (200);

    //  By default PUSH sockets block if there's no peer
    zsock_set_sndtimeo (*server, 200);
    zstr_send (*server, "Hello, World");

    zpoller_t *poller = zpoller_new (*client, NULL);
    bool success = (zpoller_wait (poller, 400) == *client);
    zpoller_destroy (&poller);
    zsocket_destroy (ctx, *client);
    zsocket_destroy (ctx, *server);
    *server = zsocket_new (ctx, ZMQ_PUSH);
    assert (*server);
    *client = zsocket_new (ctx, ZMQ_PULL);
    assert (*client);
    return success;
}
开发者ID:AxelVoitier,项目名称:czmq,代码行数:26,代码来源:zauth_v2.c

示例3: zyre_node_new

static zyre_node_t *
zyre_node_new (zctx_t *ctx, void *pipe)
{
    zyre_node_t *self = (zyre_node_t *) zmalloc (sizeof (zyre_node_t));
    self->ctx = ctx;
    self->pipe = pipe;
    self->inbox = zsocket_new (ctx, ZMQ_ROUTER);
    if (self->inbox == NULL) {
        free (self);
        return NULL;            //  Interrupted 0MQ call
    }
    self->port = zsocket_bind (self->inbox, "tcp://*:*");
    if (self->port < 0) {
        zsocket_destroy(self->ctx, self->inbox);
        free (self);
        return NULL;            //  Interrupted 0MQ call
    }
    self->beacon = zbeacon_new (self->ctx, ZRE_DISCOVERY_PORT);
    if (!self->beacon) {
        zsocket_destroy(self->ctx, self->inbox);
        free (self);
        return NULL;            //  Exhausted process sockets
    }
    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);

    return self;
}
开发者ID:mjhowell,项目名称:zyre,代码行数:32,代码来源:zyre_node.c

示例4: test_zmq

static void test_zmq (flux_reactor_t *reactor)
{
    zctx_t *zctx;
    void *zs[2];
    flux_watcher_t *r, *w;

    ok ((zctx = zctx_new ()) != NULL,
        "zmq: created zmq context");
    zs[0] = zsocket_new (zctx, ZMQ_PAIR);
    zs[1] = zsocket_new (zctx, ZMQ_PAIR);
    ok (zs[0] && zs[1]
        && zsocket_bind (zs[0], "inproc://test_zmq") == 0
        && zsocket_connect (zs[1], "inproc://test_zmq") == 0,
        "zmq: connected ZMQ_PAIR sockets over inproc");
    r = flux_zmq_watcher_create (reactor, zs[0], FLUX_POLLIN, zmqreader, NULL);
    w = flux_zmq_watcher_create (reactor, zs[1], FLUX_POLLOUT, zmqwriter, NULL);
    ok (r != NULL && w != NULL,
        "zmq: nonblocking reader and writer created");
    flux_watcher_start (r);
    flux_watcher_start (w);
    ok (flux_reactor_run  (reactor, 0) == 0,
        "zmq: reactor ran to completion after %d messages", zmqwriter_msgcount);
    flux_watcher_stop (r);
    flux_watcher_stop (w);
    flux_watcher_destroy (r);
    flux_watcher_destroy (w);

    zsocket_destroy (zctx, zs[0]);
    zsocket_destroy (zctx, zs[1]);
    zctx_destroy (&zctx);
}
开发者ID:surajpkn,项目名称:flux-core,代码行数:31,代码来源:reactor.c

示例5: printf

PoolFrontend::~PoolFrontend() {
	
	printf("PoolFrontend stopped.\n");
	
	zsocket_destroy(mCtx, mRouter);
	zsocket_destroy(mCtx, mDealer);
	
	zctx_destroy(&mCtx);
	
}
开发者ID:LongAndShort,项目名称:xpmpool,代码行数:10,代码来源:pool.cpp

示例6: zre_peer_connect

void
zre_peer_connect (zre_peer_t *self, char *reply_to, char *endpoint)
{
    //  If already connected, destroy old socket and start again
    if (self->connected)
        zsocket_destroy (self->ctx, self->mailbox);

    //  Create new outgoing socket (drop any messages in transit)
    self->mailbox = zsocket_new (self->ctx, ZMQ_DEALER);
    
    //  Set our caller 'From' identity so that receiving node knows
    //  who each message came from.
    zsocket_set_identity (self->mailbox, reply_to);

    //  Set a high-water mark that allows for reasonable activity
    zsocket_set_sndhwm (self->mailbox, PEER_EXPIRED * 100);
    
    //  Send messages immediately or return EAGAIN
    zsocket_set_sndtimeo (self->mailbox, 0);
    
    //  Connect through to peer node
    zsocket_connect (self->mailbox, "tcp://%s", endpoint);
    self->endpoint = strdup (endpoint);
    self->connected = true;
    self->ready = false;
}
开发者ID:richxnh,项目名称:zyre,代码行数:26,代码来源:zre_peer.c

示例7: prob_disconnect

void
prob_disconnect(prob_client_t pc)
{
    if (zsocket_disconnect(pc->zocket, "%s", pc->file) != 0) Warning(info, "Could not disconnect from zocket %s", pc->file);
    zsocket_destroy(pc->ctx, pc->zocket);
    zctx_destroy(&(pc->ctx));
}
开发者ID:Meijuh,项目名称:ltsmin,代码行数:7,代码来源:prob_client.c

示例8: do_heartbeat

static gboolean
do_heartbeat (GPPWorker *self)
{
  GPPWorkerPrivate *priv = GET_PRIV (self);
  if (--priv->liveness == 0) {
    g_warning ("W: heartbeat failure, can't reach queue\n");
    g_warning ("W: reconnecting in %zd msec...\n", priv->interval);
    g_source_remove (priv->frontend_source);
    priv->frontend_source = 0;
    g_io_channel_unref (priv->frontend_channel);

    if (priv->interval < INTERVAL_MAX)
      priv->interval *= 2;

    zsocket_destroy (priv->ctx, priv->frontend);
    g_timeout_add (priv->interval, (GSourceFunc) do_start, self);
    return FALSE;
  }

  zframe_t *frame = zframe_new (PPP_HEARTBEAT, 1);
  zframe_send (&frame, priv->frontend, 0);
  /* We need to do that for some reason ... */
  check_socket_activity (priv->frontend_channel, G_IO_IN, self);
  return TRUE;
}
开发者ID:MathieuDuponchelle,项目名称:GPP,代码行数:25,代码来源:gppworker.c

示例9: s_can_connect

//  Checks whether client can connect to server
static bool
s_can_connect (zctx_t *ctx, void **server, void **client)
{
    int port_nbr = zsocket_bind (*server, "tcp://127.0.0.1:*");
    assert (port_nbr > 0);
    int rc = zsocket_connect (*client, "tcp://127.0.0.1:%d", port_nbr);
    assert (rc == 0);
    zstr_send (*server, "Hello, World");
    zpoller_t *poller = zpoller_new (*client, NULL);
    bool success = (zpoller_wait (poller, 200) == *client);
    zpoller_destroy (&poller);
    zsocket_destroy (ctx, *client);
    zsocket_destroy (ctx, *server);
    *server = zsocket_new (ctx, ZMQ_PUSH);
    *client = zsocket_new (ctx, ZMQ_PULL);
    return success;
}
开发者ID:guruofquality,项目名称:czmq,代码行数:18,代码来源:zauth.c

示例10: closeZMQ

/* closeZMQ will destroy the context and 
 * associated socket
 */
static void closeZMQ(instanceData* pData) {
    errmsg.LogError(0, NO_ERRCODE, "closeZMQ called");
    if(s_context && pData->socket) {
        if(pData->socket != NULL) {
            zsocket_destroy(s_context, pData->socket);
        }
    }
}
开发者ID:VerizonDigital,项目名称:rsyslog,代码行数:11,代码来源:omzmq3.c

示例11: test_line

char *  test_line() {
  zctx_t *context = zctx_new();
  lineconfig_t config;
  config.line_id = 2;
  config_t base = { "uuid", "inproc:broker", "inproc:portwatcher",
                         "inproc:registration", "http://something.com" };
  config.base_config = &base;

  void * line_in = zsocket_new(context, ZMQ_PUB);
  zsocket_bind (line_in, "inproc://line");
  // filter(identity, serial_reader, remote, context);
  
  zclock_log("pre-fork");
  void * pipe = zthread_fork(context, line_listener, &config);
  // TODO a real test
  zstr_send(pipe, "ping");
  char * result = zstr_recv(pipe);
  mu_assert_str("pong response", "pong", result);
  free(result);
  // do some channel switching
  int i,j;
  for(i=0;i<100;i++) {
    // first channel
    for(j=0;j<3; j++) {
      val_msg(line_in, "foo", 12);
    }
    for(j=0;j<3;j++) {
      val_msg(line_in, "bar", 99);
    }
  }

  zstr_send(line_in, "DESTROY");
  // temp
  printf("destroy message sent\n");
  result = zstr_recv(pipe);
  mu_assert_str("destroy response", "ok", result);
  free(result);
  zsocket_destroy(context,pipe);
  printf("freed pipe\n");
  zsocket_destroy(context, line_in);

  zctx_destroy(&context);

  return NULL;
}
开发者ID:saidimu,项目名称:ninjaduino,代码行数:45,代码来源:test_line.c

示例12: s_mdp_client_connect_to_broker

void s_mdp_client_connect_to_broker (mdp_client_t *self)
{
    if (self->client)
        zsocket_destroy (self->ctx, self->client);
    self->client = zsocket_new (self->ctx, ZMQ_DEALER);
    zmq_connect (self->client, self->broker);
    if (self->verbose)
        zclock_log ("I: connecting to broker at %s...", self->broker);
}
开发者ID:Notificare,项目名称:majordomo,代码行数:9,代码来源:mdp_client.c

示例13: client_task

static void 
client_task (void *args)
{
    client_state* state = (client_state*) args;
    void *frontend = zsocket_new (state->context, ZMQ_DEALER);
    zsocket_set_identity (frontend, state->identity);
    zsocket_connect (frontend,state->server_url);
    
    void *backend = zsocket_new (state->context, ZMQ_DEALER);
    zsocket_bind (backend, "inproc://backend");
    zthread_fork (state->context, worker_task, state);
    
    client_loop(state, frontend, backend);
    
    zsocket_destroy(state->context, &frontend);
    zsocket_destroy(state->context, &backend);
    zctx_destroy (&state->context);
}
开发者ID:gloryofrobots,项目名称:zmq_chat_example,代码行数:18,代码来源:zchat_client.cpp

示例14: zsocket_destroy

void *_rrwrk_create_socket(zctx_t *ctx, void *socket, int type)
{
    if (socket) {
        zsocket_destroy(ctx, socket); //** Destroy existing socket
    }
    socket = zsocket_new(ctx, type);
    assert(socket);

    return socket;
}
开发者ID:PerilousApricot,项目名称:lstore-toolbox,代码行数:10,代码来源:rr_wrk.c

示例15: collabclient_sessionReconnect

void collabclient_sessionReconnect( void* ccvp )
{
#ifdef BUILD_COLLAB

    cloneclient_t* cc = (cloneclient_t*)ccvp;

    zsocket_destroy( cc->ctx, cc->snapshot   );
    zsocket_destroy( cc->ctx, cc->subscriber );
    zsocket_destroy( cc->ctx, cc->publisher  );
    collabclient_remakeSockets( cc );
    cc->publisher_sendseq = 1;

    FontView* fv = FontViewFindUI( FontViewFind_byCollabPtr, cc );
    if( fv )
    {
	collabclient_sessionJoin( cc, fv );
    }

#endif
}
开发者ID:Decepticoner,项目名称:fontforge,代码行数:20,代码来源:collabclientui.c


注:本文中的zsocket_destroy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。