From 68d23225a38a35f1325eb39fa4ed5a005d5de473 Mon Sep 17 00:00:00 2001 From: fujuntang <fujuntang@aiot.com> Date: 星期三, 11 八月 2021 09:50:20 +0800 Subject: [PATCH] fix from 3.1 first commit --- README.md | 295 +--------------------------------------------------------- 1 files changed, 7 insertions(+), 288 deletions(-) diff --git a/README.md b/README.md index 36dae67..2d46af1 100644 --- a/README.md +++ b/README.md @@ -1,293 +1,12 @@ -# 1. 瀹炰緥 -浠ヤ笅瀹炰緥浠g爜鍦╜demo`鏂囦欢澶逛笅 -## 1.1 Bus妯″紡 -**Source** - -`dgram_mod_bus.c` - -**缂栬瘧** - -瀹夎濂絪o鍖呭悗锛岀敤濡備笅鐨勬柟寮忕紪璇戯紝shm_queue鏄�氫俊闃熷垪鍖咃紝usgcommon鏄叕鍏卞寘锛宲thread鏄郴缁熺殑绾跨▼鍖� -`g++ dgram_mod_bus.c -mcx16 -std=c++11 -lshm_queue -lusgcommon -lpthread` - -**婕旂ず** - -鍚姩bus `./dgram_mod_bus server 8`銆傜劧鍚庢墦寮�涓や釜瀹㈡埛绔繛鎺us锛� 绗竴涓鎴风璁㈤槄 "news", 绗簩涓鎴风鍙戝竷 "news". 绗竴涓鎴风浼氭敹鍒扮浜屼釜瀹㈡埛绔帹閫佺殑淇℃伅銆� - -鍚姩bus -``` -$ ./dgram_mod_bus server 8 -``` - -绗竴涓鎴风璁㈤槄 "news" -``` - -$ ./dgram_mod_bus client 8 -Can I help you? sub, pub or quit -sub -Please input topic! -news -Sub success! -Can I help you? sub, pub or quit -鏀跺埌璁㈤槄娑堟伅:111111111111111111111 - - ``` -绗簩涓鎴风鍙戝竷 "news" - ``` -$ ./dgram_mod_bus client 8 -Can I help you? sub, pub or quit -pub -Please input topic and content -news 111111111111111111111 -Pub success! -Can I help you? sub, pub or quit - - ``` -杩欓噷鍙互鎵撳紑璁稿涓鎴风鍙戝竷鍜岃闃呮秷鎭�� +# 缂栬瘧 +``` + ./build.sh release +``` -## 1.2 req_rep妯″紡, 閫傚簲浜庢敞鍐� +# 鐢熸垚API鏂囨。 -**Source** `dgram_mod_req_rep.c` - -**缂栬瘧** 鍚屼笂 - -**婕旂ず** - ``` -## 鍚姩娉ㄥ唽涓績 -./dgram_mod_req_rep server 2 & node0=$! && sleep 1 -## 鍚戞敞鍐屼腑蹇冨彂閫佹秷鎭� -./dgram_mod_req_rep client 2 node1 -kill $node0 -``` - -## survey妯″紡锛� 閫傚簲浜庡績璺� -**Source** `dgram_mod_survey.c` - -**缂栬瘧** 鍚屼笂 - -**婕旂ず** -鍚姩蹇冭烦涓績 -``` -$ ./dgram_mod_survey server 3 - -RECEIVED HREARTBEAT FROM 1000: 0 -RECEIVED HREARTBEAT FROM 1000: 1 -RECEIVED HREARTBEAT FROM 1000: 2 -RECEIVED HREARTBEAT FROM 1000: 3 -RECEIVED HREARTBEAT FROM 1000: 4 -RECEIVED HREARTBEAT FROM 1000: 5 -RECEIVED HREARTBEAT FROM 1000: 6 -RECEIVED HREARTBEAT FROM 1000: 7 -RECEIVED HREARTBEAT FROM 1000: 8 -RECEIVED HREARTBEAT FROM 1000: 9 - -``` - -鎵撳紑涓�涓鎴风锛岃繛鎺ュ績璺充腑蹇� -``` -$ ./dgram_mod_survey client 3 - -SEND HEART:0 -SEND HEART:1 -SEND HEART:2 -SEND HEART:3 -SEND HEART:4 -SEND HEART:5 -SEND HEART:6 -SEND HEART:7 -SEND HEART:8 -SEND HEART:9 - -``` - -# 1.3 缃戠粶娴嬭瘯 - - - -鍦ㄤ笁涓妭鐐逛笂node1 node2 node3 鍒嗗埆鎵ц涓嬮潰鐨勭▼搴� -``` - -# 鎵撳紑璇锋眰搴旂瓟鐨剆erver -./dgram_mod_req_rep server 11 & - -# 寮�鍚痓us -./dgram_mod_bus server 8 & - -# 寮�鍚綉缁渟erver -./net_mod_socket server 5000 & - -# 璁㈤槄bus -./dgram_mod_bus client 8 -``` - -鍦ㄥ叾涓竴涓妭鐐规墽琛岀綉缁滃鎴风绋嬪簭锛屽悜鍏朵粬涓変釜鑺傜偣鍙戦�佹秷鎭� - -``` -./net_mod_socket client 5000 -``` - -# 2. 鎺ュ彛璇存槑 - -shm_mm_wraper.h -``` -/** - * 鍒濆鍖栧叡浜唴瀛� - * @size 鍏变韩鍐呭瓨澶у皬, 鍗曚綅M - * - */ -void shm_mm_wrapper_init(int size); - -/** - * 閿�姣佸叡浜唴瀛� - * 鏁翠釜杩涚▼閫�鍑烘椂闇�瑕佹墽琛岃繖涓柟娉曪紝璇ユ柟娉曢鍏堜細妫�鏌ユ槸鍚﹁繕鏈夊叾浠栬繘绋嬪湪浣跨敤璇ュ叡浜唴瀛橈紝濡傛灉杩樻湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ氨鍙槸detach,濡傛灉娌℃湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ垯閿�姣佹暣鍧楀唴瀛樸�� - */ -void shm_mm_wrapper_destroy(); -``` - -dgram_mod_socket.h -``` - -/** - * 鍒涘缓socket - * @return socket鍦板潃 -*/ -void *dgram_mod_open_socket(); - -/** - * 鍏抽棴socket - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -*/ -int dgram_mod_close_socket(void * _socket); - -/** - * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -*/ -int dgram_mod_bind(void * _socket, int port); - -/** - * 鍙戦�佷俊鎭� - * @port 鍙戦�佺粰璋� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 - */ -int dgram_mod_sendto(void *_socket, const void *buf, const int size, const int port); - - -/** - * 鎺ユ敹淇℃伅 - * @port 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -*/ -int dgram_mod_recvfrom(void *_socket, void **buf, int *size, int *port); - -/** - * 鍙戦�佽姹備俊鎭苟绛夊緟鎺ユ敹搴旂瓟 - * @port 鍙戦�佺粰璋� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -*/ -int dgram_mod_sendandrecv(void * _socket, const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size) ; - - -/** - * 鍚姩bus - * - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -*/ -int dgram_mod_start_bus(void * _socket); - -/** - * 璁㈤槄鎸囧畾涓婚 - * @topic 涓婚 - * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 - */ -int dgram_mod_sub(void * _socket, void *topic, int size, int port); - -/** - * 鍙戝竷涓婚 - * @topic 涓婚 - * @content 涓婚鍐呭 - * @port 鎬荤嚎绔彛 - */ -int dgram_mod_pub(void * _socket, void *topic, int topic_size, void *content, int content_size, int port); - - -/** - * 鑾峰彇soket绔彛鍙� - */ -int dgram_mod_get_port(void * _socket) ; - - -/** - * 閲婃斁瀛樺偍鎺ユ敹淇℃伅鐨刡uf - */ -void dgram_mod_free(void *buf) ; -``` - -net_mod_server_socket_wrapper.h - -``` - -/** - * 鍒涘缓 - */ -void *net_mod_server_socket_open(int port) ; - -/** - * 鍏抽棴 - */ -void net_mod_server_socket_close(void *_sockt) ; - -/** - * 鍚姩 - */ -void net_mod_server_socket_start(void *_sockt); - -``` - -net_mod_socket_wrapper.h - -``` - -/** - * 鍒涘缓 - */ -void * net_mod_socket_open(); - -/** - * 鍏抽棴 - */ -void net_mod_socket_close(void *_sockt); - -/** - * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂閫佽姹傛秷鎭紝鑺傜偣鐨勮繑鍥炰俊鎭眹鎬诲苟瀛樺偍鍦╮ecv_arr涓� - * @node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴� - * @send_buf 鍙戦�佺殑娑堟伅锛孈send_size 璇ユ秷鎭綋鐨勯暱搴� - * @recv_arr 杩斿洖鐨勫簲绛旀秷鎭粍锛孈recv_arr_size 璇ユ暟缁勯暱搴� - * @return 鎴愬姛鍙戦�佺殑鑺傜偣鐨勪釜鏁� - */ -int net_mod_socket_sendandrecv(void *_sockt, net_node_t *node_arr, int node_arr_len, void *send_buf, int send_size, - net_mod_recv_msg_t ** recv_arr, int *recv_arr_size); - -/** - * 閿�姣乻endandrecv鏂规硶杩斿洖鐨勬秷鎭粍 - * @arr 娑堟伅缁� - * @size 娑堟伅缁勭殑闀垮害 - */ -void net_mod_socket_free_recv_msg_arr(net_mod_recv_msg_t * arr, int size); - - /** - * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂甯冩秷鎭� - * @node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴� - * @topic 涓婚锛孈topic_size 璇ヤ富棰樼殑闀垮害 - * @content 鍐呭锛孈content_size 鍐呭闀垮害 - * @return 鎴愬姛鍙戝竷鐨勮妭鐐圭殑涓暟 - */ -int net_mod_socket_pub(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size); - -``` - - + ./build.sh doc +``` \ No newline at end of file -- Gitblit v1.8.0