From 695953440565103964e816e7326c66f3d171c3e0 Mon Sep 17 00:00:00 2001
From: jimi-wzq <wangzhengquan85@gmail.com>
Date: 星期六, 01 八月 2020 10:48:18 +0800
Subject: [PATCH] fix conflict

---
 README.md |  205 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 203 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 0054b9d..ba8d825 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,205 @@
-## softbus
+ 
+# 1. 瀹炰緥
+浠ヤ笅瀹炰緥浠g爜鍦╜demo`鏂囦欢澶逛笅
+## 1.1 Bus妯″紡
+**Source**  
 
-shm鐨勯�氳搴�
+`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
+
+ ```
+杩欓噷鍙互鎵撳紑璁稿涓鎴风鍙戝竷鍜岃闃呮秷鎭��
+ 
+
+## 1.2 req_rep妯″紡, 閫傚簲浜庢敞鍐�
+ 
+**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
+
+```
+ 
+
+# 2. 鎺ュ彛璇存槑
+
+shm_mm.h
+```
+/**
+ * 鍒濆鍖栧叡浜唴瀛�
+ * @size 鍏变韩鍐呭瓨澶у皬, 鍗曚綅M
+ * 
+ */
+void shm_init(int size);
+
+/**
+ * 閿�姣佸叡浜唴瀛�
+ * 鏁翠釜杩涚▼閫�鍑烘椂闇�瑕佹墽琛岃繖涓柟娉曪紝璇ユ柟娉曢鍏堜細妫�鏌ユ槸鍚﹁繕鏈夊叾浠栬繘绋嬪湪浣跨敤璇ュ叡浜唴瀛橈紝濡傛灉杩樻湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ氨鍙槸detach,濡傛灉娌℃湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ垯閿�姣佹暣鍧楀唴瀛樸��
+ */
+void shm_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) ;
+```
+
+ 

--
Gitblit v1.8.0