您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ zmq_init函数代码示例

51自学网 2021-06-03 12:01:03
  C++
这篇教程C++ zmq_init函数代码示例写得很实用,希望能帮到您。

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

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

示例1: PROCESS_THREAD

PROCESS_THREAD(test_pub_bind, ev, data) {    // printf("> test_pub_bind %d, %d, %p/n", process_pt->lc, ev, data);    // print_event_name(ev);    // printf("/r/n");    PROCESS_BEGIN();    zmq_init();    zmq_socket_init(&my_sock, ZMQ_PUB);    // zmq_bind("tcp://*:9999");    zmq_bind(&my_sock, 9999);    while(1) {        if(etimer_expired(&et))            etimer_set(&et, CLOCK_SECOND);        PROCESS_WAIT_EVENT();        if(ev == PROCESS_EVENT_TIMER) {            printf("Publishing 'Hi there!'/r/n");            static zmq_msg_t *msg = NULL;            msg = zmq_msg_from_const_data(0, "Hi there!", 9);            PT_WAIT_THREAD(process_pt, my_sock.send(&my_sock, msg));            zmq_msg_destroy(&msg);        }    }    PROCESS_END();}
开发者ID:Alidron,项目名称:contiki-zeromq,代码行数:28,


示例2: zmq_init

void SampleEscrowServerZmq::StartServer(){    std::printf("starting server %s on port %d/n", this->serverName.c_str(), this->serverInfo->port);    std::cout.flush();    // Prepare our context and socket    this->context = zmq_init(1);    this->serverSocket = zmq_socket(this->context, ZMQ_REP);    // Configure socket to not wait at close time    int timeOut = 3000;#ifdef OT_USE_ZMQ4    zmq_setsockopt(this->serverSocket, ZMQ_RCVTIMEO, &timeOut, sizeof(timeOut));    zmq_setsockopt(this->serverSocket, ZMQ_SNDTIMEO, &timeOut, sizeof(timeOut));#endif    int linger = 0;    zmq_setsockopt(this->serverSocket, ZMQ_LINGER, &linger, sizeof (linger));    std::string connectString = "tcp://";    connectString += this->serverInfo->url;    connectString += ":";    //connectString += btc::to_string(this->serverInfo->port);    connectString += QString::number(this->serverInfo->port).toStdString();    zmq_bind(serverSocket, connectString.c_str());}
开发者ID:plato-cambrian,项目名称:Cambrian-src,代码行数:25,


示例3: glbColl_start

/** *  glbCollection network service startup */static int glbColl_start(struct glbColl *self){    void *context;    void *frontend;    void *backend;    pthread_t storage_outlet;    int ret;    ret = pthread_create(&storage_outlet, 			 NULL, 			 glbColl_add_storage, (void*)self);    context = zmq_init(1);    frontend = zmq_socket(context, ZMQ_PULL);    backend = zmq_socket(context, ZMQ_PUSH);    zmq_bind(frontend, "tcp://127.0.0.1:6908");    zmq_bind(backend, "tcp://127.0.0.1:6909");    printf("  ++ Collection server is up and running!.../n/n");    zmq_device(ZMQ_QUEUE, frontend, backend);    /* we never get here */    zmq_close(frontend);    zmq_close(backend);    zmq_term(context);    return glb_OK;}
开发者ID:M0nsteR,项目名称:globbie_storage,代码行数:35,


示例4: main

int main (void){void *context = zmq_init (1);// Socket to talk to serverprintf ("Connecting to test_rep server... /n");void *requester = zmq_socket (context, ZMQ_REQ);zmq_connect (requester, "tcp://127.0.0.1:5555");int request_nbr;for (request_nbr = 0; request_nbr != 10; request_nbr++) {zmq_msg_t request;zmq_msg_init_size (&request, 5);memcpy (zmq_msg_data (&request), "Hello", 5);printf ("Sending Hello %d .../n", request_nbr);zmq_send (requester, &request, 0);zmq_msg_close (&request);zmq_msg_t reply;zmq_msg_init (&reply);zmq_recv (requester, &reply, 0);printf ("Received World %d/n", request_nbr);zmq_msg_close (&reply);}zmq_close (requester);zmq_term (context);return 0;}
开发者ID:ahal,项目名称:moz-zeromq,代码行数:28,


示例5: hx_zmq_construct

value hx_zmq_construct (value io_threads){	if (!val_is_int(io_threads))		return alloc_null();			int _io_threads = val_int(io_threads);	if (_io_threads <= 0) {		val_throw(alloc_int(EINVAL));		return alloc_null();	}		void *c = zmq_init (_io_threads);	int err = zmq_errno();		if (c == NULL) {		val_throw (alloc_int(err));		return alloc_null();	}		// See: http://nekovm.org/doc/ffi#abstracts_and_kinds	value v =  alloc_abstract(k_zmq_context_handle,c);	val_gc(v,finalize_context);		// finalize_context is called when the abstract value is garbage collected	return v;	}
开发者ID:boorik,项目名称:hxzmq,代码行数:25,


示例6: main

int main (void) {    s_version_assert (2, 1);    void *context = zmq_init (1);    //  Socket to talk to clients    void *publisher = zmq_socket (context, ZMQ_PUB);    zmq_bind (publisher, "tcp://*:5561");    //  Socket to receive signals    void *syncservice = zmq_socket (context, ZMQ_REP);    zmq_bind (syncservice, "tcp://*:5562");    //  Get synchronization from subscribers    int subscribers = 0;    while (subscribers < SUBSCRIBERS_EXPECTED) {        //  - wait for synchronization request        char *string = s_recv (syncservice);        free (string);        //  - send synchronization reply        s_send (syncservice, "");        subscribers++;    }    //  Now broadcast exactly 1M updates followed by END    int update_nbr;    for (update_nbr = 0; update_nbr < 1000000; update_nbr++)        s_send (publisher, "Rhubarb");    s_send (publisher, "END");    zmq_close (publisher);    zmq_close (syncservice);    zmq_term (context);    return 0;}
开发者ID:Neopallium,项目名称:zguide,代码行数:35,


示例7: main

int main (void){    fprintf (stderr, "test_pair_ipc running.../n");    void *ctx = zmq_init (1);    assert (ctx);    void *sb = zmq_socket (ctx, ZMQ_PAIR);    assert (sb);    int rc = zmq_bind (sb, "ipc:///tmp/tester");    assert (rc == 0);    void *sc = zmq_socket (ctx, ZMQ_PAIR);    assert (sc);    rc = zmq_connect (sc, "ipc:///tmp/tester");    assert (rc == 0);        bounce (sb, sc);    rc = zmq_close (sc);    assert (rc == 0);    rc = zmq_close (sb);    assert (rc == 0);    rc = zmq_term (ctx);    assert (rc == 0);    return 0 ;}
开发者ID:888,项目名称:zeromq3-x,代码行数:30,


示例8: main

int main (void){    fprintf (stderr, "test_reqrep_tipc running.../n");    void *ctx = zmq_init (1);    assert (ctx);    void *sb = zmq_socket (ctx, ZMQ_REP);    assert (sb);    int rc = zmq_bind (sb, "tipc://{5560,0,0}");    assert (rc == 0);    void *sc = zmq_socket (ctx, ZMQ_REQ);    assert (sc);    rc = zmq_connect (sc, "tipc://{5560,0}@0.0.0");    assert (rc == 0);    bounce (sb, sc);    rc = zmq_close (sc);    assert (rc == 0);    rc = zmq_close (sb);    assert (rc == 0);    rc = zmq_ctx_term (ctx);    assert (rc == 0);    return 0;}
开发者ID:cuijw,项目名称:libzmq,代码行数:30,


示例9: main

int main(int argc, char *argv[]){  if (argc < 2) return EXIT_FAILURE;  int N = atoi(argv[1]);  printf("N: %d/n", N);  void *ctx = zmq_init(1);  void *pub = zmq_socket(ctx, ZMQ_PUB); // Output channel of 0  assert(pub);  void *sub = zmq_socket(ctx, ZMQ_SUB); // Input channel of 0  assert(sub);  int rc;  rc = zmq_bind(sub, "tcp://*:8887"); // Waits for publishers  assert(rc == 0);  rc = zmq_connect(pub, "tcp://localhost:8888"); // Actively connect to subscribers  assert(rc == 0);  zmq_setsockopt(sub, ZMQ_SUBSCRIBE, "", 0);  int *val = (int *)calloc(N, sizeof(int));  zmq_msg_t msg;  long long start_time = sc_time();  // Send  int *buf = (int *)calloc(N, sizeof(int));  memcpy(buf, val, N * sizeof(int));  zmq_msg_init_data(&msg, buf, N * sizeof(int), _dealloc, NULL);  zmq_send(pub, &msg, 0);  zmq_msg_close(&msg);  // Receive  zmq_msg_init(&msg);  zmq_recv(sub, &msg, 0);  memcpy(val, (int *)zmq_msg_data(&msg), zmq_msg_size(&msg));  zmq_msg_close(&msg);  long long end_time = sc_time();  printf("%s: Time elapsed: %f sec/n", argv[0], sc_time_diff(start_time, end_time));#ifdef __DEBUG__  int i;  printf("%s [ ", argv[0]);  for (i=0; i<N; ++i) {    printf("%d ", val[i]);  }  printf("]/n");#endif  free(val);  zmq_close(sub);  zmq_close(pub);  zmq_term(ctx);  return EXIT_SUCCESS;}
开发者ID:D4vidH4mm3r,项目名称:sessc,代码行数:60,


示例10: main

//  We will do this all in one thread to emphasize the sequence//  of events...int main () {    void *context = zmq_init (1);    void *client = zmq_socket (context, ZMQ_XREP);    zmq_bind (client, "ipc://routing");    void *worker = zmq_socket (context, ZMQ_REP);    zmq_setsockopt (worker, ZMQ_IDENTITY, "A", 1);    zmq_connect (worker, "ipc://routing");    //  Wait for sockets to stabilize    sleep (1);    //  Send papa address, address stack, empty part, and request    s_sendmore (client, "A");    s_sendmore (client, "address 3");    s_sendmore (client, "address 2");    s_sendmore (client, "address 1");    s_sendmore (client, "");    s_send     (client, "This is the workload");    //  Worker should get just the workload    s_dump (worker);    //  We don't play with envelopes in the worker    s_send (worker, "This is the reply");    //  Now dump what we got off the XREP socket...    s_dump (client);    zmq_term (context);    return 0;}
开发者ID:dell-esdk,项目名称:zguide,代码行数:35,


示例11: main

int main(){    void* context = zmq_init(1);    // socket to receive msgs on: the vent    void* receiver = zmq_socket(context, ZMQ_PULL);    zmq_connect( receiver, "tcp://localhost:5557");    // socket to send msgs to: the sink    void *sender = zmq_socket( context, ZMQ_PUSH);    zmq_connect( sender, "tcp://localhost:5558");    int tasks_received = 0;    //process    while(1) {        char* string = s_recv(receiver);        fflush(stdout);        printf("%s.", string);        //do work        s_sleep(atoi(string));        free(string);        //send results to sink        s_send(sender, "");        tasks_received++;    printf("Task %d got %d tasks/n", getpid(), tasks_received);    }    zmq_close(receiver);    zmq_close(sender);    zmq_term(0);    return 0;}
开发者ID:dgquintas,项目名称:my-code-samples,代码行数:35,


示例12: main

int main (int argc, char *argv []){    void *ctx = zmq_init (1);    assert (ctx);    void *sb = zmq_socket (ctx, ZMQ_REP);    assert (sb);    int rc = zmq_bind (sb, "tcp://127.0.0.1:5555");    assert (rc == 0);    void *sc = zmq_socket (ctx, ZMQ_REQ);    assert (sc);    rc = zmq_connect (sc, "tcp://127.0.0.1:5555");    assert (rc == 0);        bounce (sb, sc);    rc = zmq_close (sc);    assert (rc == 0);    rc = zmq_close (sb);    assert (rc == 0);    rc = zmq_term (ctx);    assert (rc == 0);    return 0 ;}
开发者ID:scastillo,项目名称:libzmq,代码行数:28,


示例13: thread

Return<std::string> Zmq::init(const int type) {  std::stringstream ss;  ss << port;  endPoint = address + ":" + ss.str();  std::cout << "endPoint " << endPoint << std::endl;  if (Zmq::context == NULL){    if ((Zmq::context = zmq_init(1)) == NULL) {      return Return<std::string> (false,                                   "Failed to init zmq with 1 thread ("                                  + std::string(zmq_strerror(zmq_errno())) +")");    }  }  if ((socket = zmq_socket(Zmq::context, type)) == NULL){    return Return<std::string> (false,                                 "Failed to to create socket ("                                + std::string(zmq_strerror(zmq_errno())) +")");  }    return true;}
开发者ID:trax44,项目名称:tvirt,代码行数:25,


示例14: main

int main(){    void* context = zmq_init(1);    void* receiver = zmq_socket(context, ZMQ_PULL);    zmq_bind(receiver, "tcp://*:5558");    //wait for start of batch    char *string = s_recv(receiver);    free(string);    //start clock    int64_t start_time = s_clock();    //process 100    int tasks_nbr;    for( tasks_nbr = 0; tasks_nbr < 100; tasks_nbr++){        char* string = s_recv(receiver);        if((tasks_nbr / 10)*10 == tasks_nbr){            printf(":");        } else{            printf(".");        }        fflush(stdout);    }    printf("Total elapsed time: %d msec/n",             (int)(s_clock() - start_time));    zmq_close(receiver);    zmq_term(context);    return 0;}
开发者ID:dgquintas,项目名称:my-code-samples,代码行数:33,


示例15: worker_thread

//  Worker using REQ socket to do LRU routing//static void *worker_thread (void *args) {    void *context = zmq_init (1);    void *worker = zmq_socket (context, ZMQ_REQ);    s_set_id (worker);          //  Makes tracing easier    zmq_connect (worker, "ipc://backend.ipc");    //  Tell broker we're ready for work    s_send (worker, "READY");    while (1) {        //  Read and save all frames until we get an empty frame        //  In this example there is only 1 but it could be more        char *address = s_recv (worker);        char *empty = s_recv (worker);        assert (*empty == 0);        free (empty);        //  Get request, send reply        char *request = s_recv (worker);        printf ("Worker: %s/n", request);        free (request);        s_sendmore (worker, address);        s_sendmore (worker, "");        s_send     (worker, "OK");        free (address);    }    zmq_close (worker);    zmq_term (context);    return NULL;}
开发者ID:darksuji,项目名称:zguide,代码行数:34,


示例16: main

int main (void){    fprintf (stderr, "test_connect_resolve running.../n");    void *ctx = zmq_init (1);    assert (ctx);    //  Create pair of socket, each with high watermark of 2. Thus the total    //  buffer space should be 4 messages.    void *sock = zmq_socket (ctx, ZMQ_PUB);    assert (sock);    int rc = zmq_connect (sock, "tcp://localhost:1234");    assert (rc == 0);    rc = zmq_connect (sock, "tcp://0mq.is.teh.best:1234");    assert (rc == -1);    assert (errno == EINVAL);    rc = zmq_close (sock);    assert (rc == 0);    rc = zmq_term (ctx);    assert (rc == 0);    return 0;}
开发者ID:888,项目名称:zeromq3-x,代码行数:27,


示例17: main

int main () {    s_version_assert (2, 1);    void *context = zmq_init (1);    //  Socket to talk to clients    void *clients = zmq_socket (context, ZMQ_XREP);    zmq_bind (clients, "tcp://*:5555");    //  Socket to talk to workers    void *workers = zmq_socket (context, ZMQ_XREQ);    zmq_bind (workers, "inproc://workers");    //  Launch pool of worker threads    int thread_nbr;    for (thread_nbr = 0; thread_nbr != 5; thread_nbr++) {        pthread_t worker;        pthread_create (&worker, NULL, worker_routine, context);    }    //  Connect work threads to client threads via a queue    zmq_device (ZMQ_QUEUE, clients, workers);    //  We never get here but clean up anyhow    zmq_close (clients);    zmq_close (workers);    zmq_term (context);    return 0;}
开发者ID:gochist,项目名称:zguide,代码行数:27,


示例18: main

/* url subtitle arguments */int main (int argc, char *argv []) {  void *context = zmq_init (1);  void *subscriber = zmq_socket (context, ZMQ_SUB);  size_t title_len = 0;  assert(zmq_connect (subscriber, argv[1]) == 0);  assert(title_len = strlen(argv[2]) > 1);  assert(zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, argv[2], title_len) == 0);  Bool verbose = 0;  zloop_t *loop = zloop_new ();  assert (loop);  zloop_set_verbose (loop, verbose);  zmq_pollitem_t sub_event = { subscriber, 0, ZMQ_POLLIN };  if ( argc > 3 ) {    assert(zloop_poller (loop, &sub_event, subscriber_cb, (void*)(argv + 3)) == 0);      } else {    assert(zloop_poller (loop, &sub_event, subscriber_cb, NULL) == 0);      }  zloop_start (loop);  zloop_destroy (&loop);  assert (loop == NULL);  zmq_close (subscriber);  zmq_term (context);  return 0;}
开发者ID:bartuer,项目名称:bew,代码行数:31,


示例19: StopServer

		void teRDNetwork::StartServer(u1 asClient, const c8 * connectToIP)		{			if(zmqContext)				StopServer();			zmqContext = zmq_init(1);			if(asClient)			{				c8 temp[256];				zmqCmd = zmq_socket(zmqContext, ZMQ_REQ);				sprintf(temp, "tcp://%s:7748", connectToIP);				zmq_connect(zmqCmd, temp);				zmqDataDrop = zmq_socket(zmqContext, ZMQ_PULL);				sprintf(temp, "tcp://%s:7749", connectToIP);				zmq_connect(zmqDataDrop, temp);			}			else			{				zmqCmd = zmq_socket(zmqContext, ZMQ_REP);				zmq_bind(zmqCmd, "tcp://*:7748");				zmqDataDrop = zmq_socket(zmqContext, ZMQ_PUSH);				zmq_bind(zmqDataDrop, "tcp://*:7749");			}		}
开发者ID:EvgeniyRudnev,项目名称:tatengine,代码行数:28,


示例20: Lzmq_init

static int Lzmq_init(lua_State *L){    zmq_ptr *ctx = lua_newuserdata(L, sizeof(zmq_ptr));    luaL_getmetatable(L, MT_ZMQ_CONTEXT);    lua_setmetatable(L, -2);    if (lua_islightuserdata(L, 1)) {        // Treat a light userdata as a raw ZMQ context object, which        // we'll silently wrap.  (And we won't automatically call term        // on it.)        ctx->ptr = lua_touserdata(L, 1);        ctx->should_free = 0;        return 1;    }    int io_threads = luaL_checkint(L, 1);    ctx->ptr = zmq_init(io_threads);    if (!ctx->ptr) {        return Lzmq_push_error(L);    }    // toboolean defaults to false, but we want a missing param #2    // to mean true    if (lua_isnil(L, 2)) {        ctx->should_free = 1;    } else {        ctx->should_free = lua_toboolean(L, 2);    }    return 1;}
开发者ID:clementfarabet,项目名称:lua---parallel,代码行数:34,


示例21: main

int main(){    void *ctx, *pub;    pthread_t pid;    ctx = zmq_init(1);    pub = zmq_socket(ctx, ZMQ_PUB);    zmq_bind(pub, "inproc://in-pub");    zmq_bind(pub, "tcp://127.0.0.1:8888");    pthread_create(&pid, NULL, sub_thread, ctx);    int i = 0;    printf("begin pub!/n");    while (1)    {        char msg[80];        sprintf(msg, "num %d", i++);        s_send(pub, msg);        sleep(2);    }    zmq_close(pub);    zmq_term(ctx);    return 0;}
开发者ID:squareqwer,项目名称:practice,代码行数:26,


示例22: Server_serve

intServer_serve(Server *server){	int rc;	void *ctx, *s;	zmq_msg_t query, resultset;	const char *cmd_name, *query_string, *resultset_string = "OK";	char endpoint[128];	/* Start up the 0MQ server */	ctx = zmq_init(1);	assert (ctx);	s = zmq_socket(ctx, ZMQ_REP);	assert (s);	sprintf(endpoint, "tcp://%s:%d", server->host, server->port);	rc = zmq_bind(s, endpoint);	assert (rc == 0);		sort_command_table();	/* Start the request/reply loop */	while (1) {		rc = zmq_msg_init(&query);		assert (rc == 0);		rc = zmq_recv(s, &query, 0);		assert (rc == 0);		if (!Server_react(server, s, &query)) {			ERROR("unrecognized command");		}	}		return 1;}
开发者ID:jdp,项目名称:ephemeron,代码行数:33,


示例23: LogPrint

// Called at startup to conditionally set up ZMQ socket(s)bool CZMQNotificationInterface::Initialize(){    LogPrint("zmq", "zmq: Initialize notification interface/n");    assert(!pcontext);    pcontext = zmq_init(1);    if (!pcontext)    {        zmqError("Unable to initialize context");        return false;    }    std::list<CZMQAbstractNotifier*>::iterator i=notifiers.begin();    for (; i!=notifiers.end(); ++i)    {        CZMQAbstractNotifier *notifier = *i;        if (notifier->Initialize(pcontext))        {            LogPrint("zmq", "  Notifier %s ready (address = %s)/n", notifier->GetType(), notifier->GetAddress());        }        else        {            LogPrint("zmq", "  Notifier %s failed (address = %s)/n", notifier->GetType(), notifier->GetAddress());            break;        }    }    if (i!=notifiers.end())    {        return false;    }    return true;}
开发者ID:BTCDDev,项目名称:bitcoin,代码行数:36,


示例24: main

int main(){    int i;    char text[80];    void *ctx, *push;    zmq_msg_t msg;    ctx = zmq_init(1);    push = zmq_socket(ctx, ZMQ_PUSH);    zmq_bind(push, "tcp://127.0.0.1:8888");    i = 0;    while (1)    {        sprintf(text, "msg #%d", i);        zmq_msg_init_size(&msg, strlen(text)+1);        memcpy(zmq_msg_data(&msg), text, strlen(text)+1);        zmq_send(push, &msg, 0);        zmq_msg_close(&msg);        i++;        sleep(1);    }    return 0;}
开发者ID:DaisyCoder,项目名称:kasicass,代码行数:27,


示例25: main

int main (void) {    void *context = zmq_init (1);    void *sink = zmq_socket (context, ZMQ_XREP);    zmq_bind (sink, "inproc://example");    //  First allow 0MQ to set the identity    void *anonymous = zmq_socket (context, ZMQ_REQ);    zmq_connect (anonymous, "inproc://example");    s_send (anonymous, "XREP uses a generated UUID");    s_dump (sink);    //  Then set the identity ourself    void *identified = zmq_socket (context, ZMQ_REQ);    zmq_setsockopt (identified, ZMQ_IDENTITY, "Hello", 5);    zmq_connect (identified, "inproc://example");    s_send (identified, "XREP socket uses REQ's socket identity");    s_dump (sink);    zmq_close (sink);    zmq_close (anonymous);    zmq_close (identified);    zmq_term (context);    return 0;}
开发者ID:dcramer,项目名称:zguide,代码行数:26,


示例26: main

int main (void){    void *context = zmq_init (1);     //  连接至服务端的套接字    printf ("正在连接至hello world服务端.../n");    void *requester = zmq_socket (context, ZMQ_REQ);    zmq_connect (requester, "tcp://localhost:5555");     int request_nbr;    for (request_nbr = 0; request_nbr != 10; request_nbr++) {        zmq_msg_t request;        zmq_msg_init_size (&request, 5);        memcpy (zmq_msg_data (&request), "Hello", 5);        printf ("正在发送 Hello %d.../n", request_nbr);        zmq_send (requester, &request, 0);        zmq_msg_close (&request);         zmq_msg_t reply;        zmq_msg_init (&reply);        zmq_recv (requester, &reply, 0);        printf ("接收到 World %d/n", request_nbr);        zmq_msg_close (&reply);    }    zmq_close (requester);    zmq_term (context);    return 0;}
开发者ID:lcygithub,项目名称:Pylearn,代码行数:28,


示例27: zmq_init

void *glbColl_add_storage(void *arg){    void *context;    void *frontend;    void *backend;    int ret;    context = zmq_init(1);    frontend = zmq_socket(context, ZMQ_SUB);    if (!frontend) pthread_exit(NULL);    zmq_bind(frontend, "tcp://127.0.0.1:6910");    zmq_setsockopt(frontend, ZMQ_SUBSCRIBE, "", 0);    backend = zmq_socket(context, ZMQ_PUB);    if (!backend) pthread_exit(NULL);    zmq_bind(backend, "tcp://127.0.0.1:6911");    printf("    ++ Collection storage device ready..../n");    zmq_device(ZMQ_FORWARDER, frontend, backend);    /* we never get here */    zmq_close(frontend);    zmq_close(backend);    zmq_term(context);    return;}
开发者ID:M0nsteR,项目名称:globbie_storage,代码行数:29,


示例28: init_zeromq_pool

int init_zeromq_pool(struct zeromq_pool * zpool){	WRITE_FMT_LOG(LOG_DEBUG, "%p", zpool);	if ( !zpool ) return ERR_BAD_ARG;	int err = 0;	/*create zmq context, it should be destroyed in zeromq_term; all opened sockets should be closed	 *before finishing, either zmq_term will wait in internal loop for completion of all I/O requests*/	zpool->context = zmq_init(1);	if ( zpool->context ){			zpool->count_max=ESOCKF_ARRAY_GRANULARITY;		/*allocated memory for array should be free at the zeromq_term */		zpool->sockf_array = malloc(zpool->count_max * sizeof(struct sock_file_t));		if ( zpool->sockf_array ) {			memset(zpool->sockf_array, '/0', zpool->count_max*sizeof(struct sock_file_t));			for (int i=0; i < zpool->count_max; i++)				zpool->sockf_array[i].unused = 1;			err = ERR_OK;		}		else{			/*no memory allocated			 * This code section can't be covered by unit tests because it's not depends from zpool parameter;			 * sockf_array member is completely setups internally*/			WRITE_FMT_LOG(LOG_ERR, "%d bytes alloc error", (int)sizeof(struct sock_file_t));			err = ERR_NO_MEMORY;		}	}	else{		/* This code section can't be covered by unit tests because it's not depends from zpool parameter;		 * it's only can be produced as unexpected zeromq error*/		WRITE_FMT_LOG(LOG_ERR, "zmq_init err %d, errno %d errtext %s/n", err, zmq_errno(), zmq_strerror(zmq_errno()));		err = ERR_ERROR;	}	return err;}
开发者ID:YaroslavLitvinov,项目名称:DistrSort-ClientServ,代码行数:34,


示例29: main

intmain(int argc, char *argv){    int i = 0;    char msg[10] = "aaaaaaaaaa";    void *context = zmq_init(1);    void *sender = zmq_socket(context, ZMQ_PUSH);    zmq_msg_t m;    printf("%d bind/n", zmq_bind(sender, "tcp://*:3333"));    //printf("%d bind/n", zmq_bind(sender, "ipc:///tmp/zmqpy_bench"));    for (i = 0; i < 10000000; i++) {        if (i % 10000 == 0)            printf("%d/n", i);#if (ZMQ_VERSION_MAJOR == 3)        zmq_send(sender, msg, 10, 0);#else        zmq_msg_init_data(&m, msg, 10, NULL, 0);        zmq_send(sender, &m, 0);        zmq_msg_close(&m);#endif    }    zmq_close(sender);    zmq_term(context);}
开发者ID:pfw,项目名称:zmqpy,代码行数:29,


示例30: main

int main (void){    if (!is_tipc_available ()) {        printf ("TIPC environment unavailable, skipping test/n");        return 77;    }    fprintf (stderr, "test_pair_tipc running.../n");    void *ctx = zmq_init (1);    assert (ctx);    void *sb = zmq_socket (ctx, ZMQ_PAIR);    assert (sb);    int rc = zmq_bind (sb, "tipc://{5560,0,0}");    assert (rc == 0);    void *sc = zmq_socket (ctx, ZMQ_PAIR);    assert (sc);    rc = zmq_connect (sc, "tipc://{5560,0}@0.0.0");    assert (rc == 0);    bounce (sb, sc);    rc = zmq_close (sc);    assert (rc == 0);    rc = zmq_close (sb);    assert (rc == 0);    rc = zmq_ctx_term (ctx);    assert (rc == 0);    return 0;}
开发者ID:dand-oss,项目名称:libzmq,代码行数:35,



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


C++ zmq_msg_close函数代码示例
C++ zmq_errno函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。