CZMQ使用举例

1、源代码czmqtest.c

#include 
int main (void)
{
    zsock_t *push = zsock_new_push ("inproc://example");
    zsock_t *pull = zsock_new_pull ("inproc://example");
    zstr_send (push, "Hello, World");

    char *string = zstr_recv (pull);
    puts (string);
    zstr_free (&string);

    zsock_destroy (&pull);
    zsock_destroy (&push);
    return 0;
}

2、编译

[root@localhost czmqtest]# pwd
/root/zeromq/czmqtest
[root@localhost czmqtest]# gcc -o czmq czmq.c -lzmq -lczmq
[root@localhost czmqtest]#


3、运行

[root@localhost czmqtest]# ./czmq
Hello, World
[root@localhost czmqtest]#


你可能感兴趣的:(ZeroMQ/CZMQ)