{"id":276112,"date":"2023-06-27T20:08:17","date_gmt":"2023-06-27T12:08:17","guid":{"rendered":"https:\/\/lrxjmw.cn\/lmqsazlxtzn.html"},"modified":"2023-06-27T20:08:17","modified_gmt":"2023-06-27T12:08:17","slug":"lmqsazlxtzn","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lmqsazlxtzn.html","title":{"rendered":"\u96f6MQ\u8f7b\u677e\u5b89\u88c5\uff1aLinux\u7cfb\u7edf\u6307\u5357"},"content":{"rendered":"

\u60f3\u8981\u8fdb\u884c\u5206\u5e03\u5f0f\u901a\u4fe1\uff0c\u9009\u62e9 zeromq \u4f5c\u4e3a\u6d88\u606f\u4f20\u9012\u6846\u67b6\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5728 Linux<\/a> \u7cfb\u7edf<\/a>\u4e0a\u5b89\u88c5<\/a> zeromq \u7684\u5168\u8fc7\u7a0b\uff0c\u5305\u62ec\u73af\u5883\u914d\u7f6e\u3001\u4f9d\u8d56\u5b89\u88c5\u3001\u6e90\u7801\u7f16\u8bd1\u7b49\u65b9\u9762\uff0c\u5e2e\u52a9\u5927\u5bb6\u5feb\u901f\u4e0a\u624b\u4f7f\u7528 zeromq \u8fdb\u884c\u5206\u5e03\u5f0f\u901a\u4fe1\u3002<\/p>\n

1.\u51c6\u5907\u5de5\u4f5c<\/b><\/p>\n

\u5728\u8fdb\u884c zeromq \u7684\u5b89\u88c5\u524d\uff0c\u9700\u8981\u5148\u51c6\u5907\u597d\u76f8\u5173\u7684\u73af\u5883\u548c\u5de5\u5177\u3002\u672c\u6587\u4ee5 Ubuntu 20.04 LTS \u64cd\u4f5c\u7cfb\u7edf\u4e3a\u4f8b\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n

2.\u5b89\u88c5\u4f9d\u8d56<\/b><\/p>\n

\u5728\u8fdb\u884c zeromq \u7684\u7f16\u8bd1\u548c\u5b89\u88c5\u524dlinux\u64cd\u4f5c\u7cfb\u7edf\u8bba\u6587\uff0c\u9700\u8981\u5148\u5b89\u88c5\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u5728 Ubuntu \u7cfb\u7edf\u4e0b\u5b89\u88c5\u4f9d\u8d56\u7684\u547d\u4ee4<\/a>\uff1a<\/p>\n

\n

\nsudo apt-get update\nsudo apt-get install -y libtool autoconf automake uuid-dev build-essential pkg-config\n<\/pre>\n<\/p>\n

3.\u4e0b\u8f7d\u6e90\u7801<\/b><\/p>\n

\u4e0b\u8f7d zeromq \u7684\u6e90\u7801\u6587\u4ef6\uff0c\u5e76\u89e3\u538b\u5230\u6307\u5b9a\u76ee\u5f55\u4e0b\u3002<\/p>\n

\n

\nwget \ntar -xzvf zeromq-4.3.4.tar.gz\ncd zeromq-4.3.4\n<\/pre>\n<\/p>\n

4.\u7f16\u8bd1\u5b89\u88c5<\/b><\/p>\n

\u8fdb\u5165\u89e3\u538b\u540e\u7684 zeromq \u6e90\u7801\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u548c\u5b89\u88c5\u3002<\/p>\n

\n

\n.\/configure\nmake\nsudo make install\n<\/pre>\n<\/p>\n

5.\u6d4b\u8bd5\u5b89\u88c5<\/b><\/p>\n

\u5728\u5b89\u88c5\u5b8c\u6210\u540ezeromq linux \u5b89\u88c5<\/strong>\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6d4b\u8bd5 zeromq \u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n

\n

\nldconfig -v| grep zmq\n<\/pre>\n<\/p>\n

\u5982\u679c\u8f93\u51fa\u4ee5\u4e0b\u5185\u5bb9zeromq linux \u5b89\u88c5<\/strong>\uff0c\u5219\u8bf4\u660e zeromq \u5b89\u88c5\u6210\u529f\u3002<\/p>\n

\n

\nlibzmq.so.5-> libzmq.so.5.2.4\n<\/pre>\n<\/p>\n

6.\u7f16\u8bd1\u793a\u4f8b\u7a0b\u5e8f<\/b><\/p>\n

\u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u7f16\u8bd1 zeromq \u7684\u793a\u4f8b\u7a0b\u5e8f\u6765\u6d4b\u8bd5 zeromq \u662f\u5426\u6b63\u5e38\u5de5\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u53d1\u5e03-\u8ba2\u9605\u6a21\u5f0f\u7684\u793a\u4f8b\u7a0b\u5e8f\u3002<\/p>\n

\n

\n#include <zmq.h>\n#include <stdio.h>\n#include <unistd.h>\n#include <string.h>\nint main (void)\n{\n    void *context = zmq_ctx_new ();\n    void *publisher = zmq_socket (context, ZMQ_PUB);\n    int rc = zmq_bind (publisher,"tcp:\/\/*:5556");\n    if (rc !=0){\n        printf("Error: zmq_bind failed!n");\n        return -1;\n    }\n    while (1){\n        char message[20];\n        sprintf(message,"Hello world!");\n        int len = strlen(message);\n        zmq_send(publisher, message, len,0);\n        sleep(1);\n    }\n    zmq_close (publisher);\n    zmq_ctx_destroy (context);\n    return 0;\n}\n<\/pre>\n<\/p>\n

\u5982\u4f55\u5b89\u88c5linux_zeromq \u7f16\u8bd1\u5b89\u88c5_zeromq linux \u5b89\u88c5<\/p>\n

\u7f16\u8bd1\u793a\u4f8b\u7a0b\u5e8f\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

\n

\ngcc -o pub pub.c-lzmq\n<\/pre>\n<\/p>\n

7.\u8fd0\u884c\u793a\u4f8b\u7a0b\u5e8f<\/b><\/p>\n

\u5728\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8\u53d1\u5e03-\u8ba2\u9605\u6a21\u5f0f\u7684\u793a\u4f8b\u7a0b\u5e8f\u3002<\/p>\n

\n

\n.\/pub\n<\/pre>\n<\/p>\n

8.\u603b\u7ed3<\/b><\/p>\n

\u672c\u6587\u4ecb\u7ecd\u4e86\u5728 Linux \u7cfb\u7edf\u4e0a\u5b89\u88c5 zeromq \u7684\u5168\u8fc7\u7a0blinux\u793e\u533a\uff0c\u5305\u62ec\u73af\u5883\u914d\u7f6e\u3001\u4f9d\u8d56\u5b89\u88c5\u3001\u6e90\u7801\u7f16\u8bd1\u7b49\u65b9\u9762\u3002\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u76f8\u4fe1\u5927\u5bb6\u5df2\u7ecf\u80fd\u591f\u987a\u5229\u5730\u5b89\u88c5\u548c\u4f7f\u7528 zeromq \u8fdb\u884c\u5206\u5e03\u5f0f\u901a\u4fe1\u4e86\u3002<\/p>\n

9.\u53c2\u8003\u8d44\u6599<\/b><\/p>\n

1. ZeroMQ\u5b98\u7f51\uff1a<\/p>\n

2. ZeroMQ\u4ee3\u7801\u4ed3\u5e93\uff1a<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7684\u7f16\u8bd1\u548c\u5b89\u88c5\u524d\uff0c\u9700\u8981\u5148\u5b89\u88c5\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93\u6587\u4ef6\u3002\u7cfb\u7edf\u4e0b\u5b89\u88c5\u4f9d\u8d56\u7684\u547d\u4ee4\uff1a\u7684\u6e90\u7801\u6587\u4ef6\uff0c\u5e76\u89e3\u538b\u5230\u6307\u5b9a\u76ee\u5f55\u4e0b\u3002zeromq-4.zeromq-4.\u6e90\u7801\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u548c\u5b89\u88c5\u3002\u7f16\u8bd1\u793a\u4f8b\u7a0b\u5e8f\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u53d1\u5e03-\u8ba2\u9605\u6a21\u5f0f\u7684\u793a\u4f8b\u7a0b\u5e8f\u3002\u7f16\u8bd1\u793a\u4f8b\u7a0b\u5e8f\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a\u8fd0\u884c\u793a\u4f8b\u7a0b\u5e8f\u5728\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8\u53d1\u5e03-\u8ba2\u9605\u6a21\u5f0f\u7684\u793a\u4f8b\u7a0b\u5e8f\u3002\u7684\u5168\u8fc7\u7a0b\uff0c\u5305\u62ec\u73af\u5883\u914d\u7f6e\u3001\u4f9d\u8d56\u5b89\u88c5\u3001\u6e90\u7801\u7f16\u8bd1\u7b49\u65b9\u9762\u3002<\/p>\n","protected":false},"author":1,"featured_media":276113,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-276112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/276112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=276112"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/276112\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/276113"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=276112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=276112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=276112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}