From 48e47110397c894716525db219e53300c08f64dd Mon Sep 17 00:00:00 2001 From: jimi-wzq <wangzhengquan85@gmail.com> Date: 星期二, 12 一月 2021 15:27:34 +0800 Subject: [PATCH] doxygen --- /dev/null | 29 -- src/socket/net_mod_socket_wrapper.h | 368 +++++++++++++++++++++++---------- src/shm/shm_mm_wrapper.h | 41 +++ src/socket/bus_server_socket_wrapper.h | 17 + src/socket/net_mod_socket_wrapper.cpp | 111 +++++---- src/socket/net_mod_socket.h | 17 + doc/使用指南.mk | 2 src/shm/shm_mm_wrapper.cpp | 2 Doxyfile | 26 +- src/socket/net_mod_server_socket_wrapper.h | 23 + src/socket/net_mod_server_socket_wrapper.cpp | 12 11 files changed, 427 insertions(+), 221 deletions(-) diff --git a/Doxyfile b/Doxyfile index adc904d..b7ad6bb 100644 --- a/Doxyfile +++ b/Doxyfile @@ -32,7 +32,7 @@ # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "My Project" +PROJECT_NAME = "BHomeBus鎺ュ彛鏂囨。" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -58,7 +58,7 @@ # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = doxygen +OUTPUT_DIRECTORY = build/doc # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -140,7 +140,7 @@ # shortest path that makes the file name unique will be used # The default value is: YES. -FULL_PATH_NAMES = YES +FULL_PATH_NAMES = NO # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand @@ -242,7 +242,7 @@ # members will be omitted, etc. # The default value is: NO. -OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored @@ -422,7 +422,7 @@ # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -434,7 +434,7 @@ # included in the documentation. # The default value is: NO. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, @@ -512,7 +512,7 @@ # scope will be hidden. # The default value is: NO. -HIDE_SCOPE_NAMES = NO +HIDE_SCOPE_NAMES = YES # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to @@ -551,7 +551,7 @@ # name. If set to NO, the members will appear in declaration order. # The default value is: YES. -SORT_MEMBER_DOCS = YES +SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member @@ -796,7 +796,7 @@ # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, # *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. -FILE_PATTERNS = *.h +FILE_PATTERNS = *wrapper.h # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -2012,7 +2012,7 @@ # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -SEARCH_INCLUDES = YES +SEARCH_INCLUDES = NO # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by the @@ -2248,7 +2248,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing @@ -2257,7 +2257,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = NO # If the CALL_GRAPH tag is set to YES then doxygen will generate a call # dependency graph for every global function or class method. @@ -2424,4 +2424,4 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_CLEANUP = YES \ No newline at end of file +DOT_CLEANUP = YES diff --git "a/doc/\344\275\277\347\224\250\346\214\207\345\215\227.mk" "b/doc/\344\275\277\347\224\250\346\214\207\345\215\227.mk" index 4514d41..b77ef8a 100644 --- "a/doc/\344\275\277\347\224\250\346\214\207\345\215\227.mk" +++ "b/doc/\344\275\277\347\224\250\346\214\207\345\215\227.mk" @@ -3,7 +3,7 @@ ## 1. BHomeBus鍖呭惈鐨勮鑹� - NetProxyService锛堢綉缁滀唬鐞嗘湇鍔★級锛� 璐熻矗璺ㄦ満鍣ㄨ浆鍙戝彂甯冩垨璇锋眰娑堟伅 -- BusService锛� 鎬荤嚎鏈嶅姟锛�: 鍙戝竷璁㈤槄鐨勮矾鐢憋紝璐熻矗璁板綍璁㈤槄鑰呯殑娑堟伅骞舵妸鍙戝竷鑰呭彂甯冪殑娑堟伅杞彂缁欐劅鍏磋叮鐨勮闃呰�呫�� +- BusService锛堟�荤嚎鏈嶅姟锛�: 鍙戝竷璁㈤槄鐨勮矾鐢憋紝璐熻矗璁板綍璁㈤槄鑰呯殑娑堟伅骞舵妸鍙戝竷鑰呭彂甯冪殑娑堟伅杞彂缁欐劅鍏磋叮鐨勮闃呰�呫�� - Pub/Sub Client锛堝彂甯冭闃呭鎴风锛夛細 鍚態usService鍙戝竷娑堟伅鎴栬�呭湪BusService涓婅闃呮劅鍏磋叮鐨勬秷鎭� - Request/Reply Client 锛堣姹傚簲绛斿鎴风锛夛細鍚戝叾浠栨満鍣�/杩涚▼鍙戦�佽姹傛秷鎭垨鑰呬粠鍏朵粬鏈哄櫒/杩涚▼鎺ュ彈搴旂瓟娑堟伅 diff --git a/src/queue/shm_queue_wrapper.cpp b/src/queue/shm_queue_wrapper.cpp deleted file mode 100644 index b617af4..0000000 --- a/src/queue/shm_queue_wrapper.cpp +++ /dev/null @@ -1,208 +0,0 @@ -#include "shm_queue_wrapper.h" - -#include "mem_pool.h" -#include "hashtable.h" -#include "shm_queue.h" -#include "shm_allocator.h" - -typedef struct ele_t { - size_t size; - void * buf; -} ele_t; - -typedef struct shmqueue_t { - void *mqueue; -} shmqueue_t; - - - -// 绉婚櫎涓嶅寘鍚湪keys涓殑闃熷垪, -void shm_remove_queues_exclude(void *keys, int length) { - //SHMQueue<ele_t>::remove_queues_exclude((int*)keys, (size_t)length); -} - - -/** - * 鍒涘缓闃熷垪 - * @ shmqueue - * @ key 鏍囪瘑鍏变韩闃熷垪鐨勫敮涓�鏍囪瘑, key鏄竴涓寚閽堥噷闈㈠瓨鍌ㄤ簡key鐨勫�硷紝 濡傛灉key鐨勫�间负-1绯荤粺浼氳嚜鍔ㄥ垎閰嶄竴涓猭ey鍊煎苟鎶婅key鐨勫�艰祴缁檏ey鎸囬拡銆傚鏋渒ey鐨勫�间笉浼氱┖浼氭鏌ユ槸鍚︽湁閲嶅缁戝畾鐨勬儏鍐�, 鏈夐噸澶嶅氨鎶ラ敊娌℃湁灏卞垱寤洪槦鍒楀苟缁戝畾key. - * @ queue_size 闃熷垪澶у皬 - */ -void* shmqueue_create( int * key, int queue_size) { - int mkey; - hashtable_t *hashtable = mm_get_hashtable(); - if(*key == -1) { - mkey = hashtable_alloc_key(hashtable); - *key = mkey; - } else { - mkey = *key; - if(hashtable_get(hashtable, mkey)!= NULL) { - err_exit(0, "key %d has already been in used!", mkey); - return NULL; - } - } - - shmqueue_t *shmqueue = (shmqueue_t*)malloc(sizeof(shmqueue_t)); - SHMQueue<ele_t> *queue = new SHMQueue<ele_t>(mkey, queue_size); - shmqueue->mqueue = (void *)queue; - return (void *)shmqueue; -} - -/** - * 缁戝畾key鍒伴槦鍒楋紝浣嗘槸骞朵笉浼氬垱寤洪槦鍒椼�傚鏋滄病鏈夊搴旀寚瀹歬ey鐨勯槦鍒楁彁绀洪敊璇苟閫�鍑� - */ -void* shmqueue_attach(int key) { - hashtable_t *hashtable = mm_get_hashtable(); - if(hashtable_get(hashtable, key)== NULL) { - err_exit(0, "shmqueue_attach锛歛ttach queue at key %d failed!", key); - return NULL; - } - - shmqueue_t *shmqueue = (shmqueue_t*)malloc(sizeof(shmqueue_t)); - SHMQueue<ele_t> *queue = new SHMQueue<ele_t>(key, 0); - shmqueue->mqueue = (void *)queue; - return (void *)shmqueue; -} - -/** - * 閿�姣� -*/ -void shmqueue_drop(void * _shmqueue) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - delete (SHMQueue<ele_t> *)shmqueue->mqueue; - delete shmqueue; -} - -/** - * 闃熷垪鍏冪礌鐨勪釜鏁� - */ -int shmqueue_size(void * _shmqueue) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - return (int)(((SHMQueue<ele_t> *)(shmqueue->mqueue))->size()) ; -} - -/** - * 鏄惁宸叉弧 - */ -int shmqueue_full(void * _shmqueue) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - return ((SHMQueue<ele_t> *)(shmqueue->mqueue))->full(); -} - -/** - * 鏄惁涓虹┖ - */ -int shmqueue_empty(void * _shmqueue) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - return ((SHMQueue<ele_t> *)(shmqueue->mqueue))->empty(); -} - -/** - * 鍏ラ槦, 闃熷垪婊℃椂绛夊緟 - */ -int shmqueue_push(void * _shmqueue, void *src, int size) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - ele_t dest; - dest.size = size; - dest.buf = mm_malloc(size); - memcpy(dest.buf, src, size); - return ((SHMQueue<ele_t> *)(shmqueue->mqueue))->push(dest); -} - -/** - * 鍏ラ槦, 闃熷垪婊℃椂绔嬪嵆杩斿洖 - */ -int shmqueue_push_nowait(void * _shmqueue, void *src, int size) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - ele_t dest; - dest.size = size; - dest.buf = mm_malloc(size); - memcpy(dest.buf, src, size); - return ((SHMQueue<ele_t> *)(shmqueue->mqueue))->push_nowait(dest); -} - -/** - * 鍏ラ槦, 鎸囧畾鏃堕棿鍐呭叆闃熶笉鎴愬姛灏辫繑鍥� - * @sec绉� - * @nsec绾崇 - */ -int shmqueue_push_timeout(void * _shmqueue, void *src, int size, int sec, int nsec) { - - struct timespec timeout = {sec, nsec}; - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - ele_t dest; - dest.size = size; - dest.buf = mm_malloc(size); - memcpy(dest.buf, src, size); - return ((SHMQueue<ele_t> *)(shmqueue->mqueue))->push_timeout(dest, &timeout); -} - -/** - * 鍑洪槦, 闃熷垪绌烘椂绛夊緟 - */ -int shmqueue_pop(void * _shmqueue, void **dest, int *size) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - ele_t src; - - bool rv = ((SHMQueue<ele_t> *)(shmqueue->mqueue))->pop(src); - if (rv) { - void * _dest = malloc(src.size); - memcpy(_dest, src.buf, src.size); - *dest = _dest; - *size = src.size; - mm_free(src.buf); - return 1; - } else { - return 0; - } - -} - -/** - * 鍑洪槦, 闃熷垪绌烘椂绔嬪嵆杩斿洖 - */ -int shmqueue_pop_nowait(void * _shmqueue, void **dest, int *size) { - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - ele_t src; - - bool rv = ((SHMQueue<ele_t> *)(shmqueue->mqueue))->pop_nowait(src); - if (rv) { - void * _dest = malloc(src.size); - memcpy(dest, src.buf, src.size); - *dest = _dest; - *size = src.size; - mm_free(src.buf); - return 1; - } else { - return 0; - } -} - -/** - * 鍑洪槦, 鎸囧畾鏃堕棿鍐呭嚭闃熶笉鎴愬姛灏辫繑鍥� - * @sec绉� - * @nsec绾崇 - */ -int shmqueue_pop_timeout(void * _shmqueue, void **dest, int *size, int sec, int nsec) { - struct timespec timeout = {sec, nsec}; - shmqueue_t * shmqueue = (shmqueue_t *)_shmqueue; - ele_t src; - - bool rv = ((SHMQueue<ele_t> *)(shmqueue->mqueue))->pop_timeout(src, &timeout); - if (rv) { - void * _dest = malloc(src.size); - memcpy(_dest, src.buf, src.size); - *dest = _dest; - *size = src.size; - mm_free(src.buf); - return 1; - } else { - return 0; - } -} - -void shmqueue_free(void *ptr) { - free(ptr); -} - - diff --git a/src/queue/shm_queue_wrapper.h b/src/queue/shm_queue_wrapper.h deleted file mode 100644 index 369a062..0000000 --- a/src/queue/shm_queue_wrapper.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __SHM_QUEUE_WRAPPER_H__ -#define __SHM_QUEUE_WRAPPER_H__ - -#include "usg_common.h" -#include "usg_typedef.h" - - - - - -/** - * @depracate 宸插簾寮冧笉鐢� - * 绉婚櫎涓嶅寘鍚湪keys涓殑闃熷垪 - */ -void shm_remove_queues_exclude(void *keys, int length); -/** - * 鍒涘缓闃熷垪 - * @ shmqueue - * @ key 鏍囪瘑鍏变韩闃熷垪鐨勫敮涓�鏍囪瘑, key鏄竴涓寚閽堥噷闈㈠瓨鍌ㄤ簡key鐨勫�硷紝 濡傛灉key鐨勫�间负-1绯荤粺浼氳嚜鍔ㄥ垎閰嶄竴涓猭ey鍊煎苟鎶婅key鐨勫�艰祴缁檏ey鎸囬拡銆傚鏋渒ey鐨勫�间笉浼氱┖浼氭鏌ユ槸鍚︽湁閲嶅缁戝畾鐨勬儏鍐�, 鏈夐噸澶嶅氨鎶ラ敊娌℃湁灏卞垱寤洪槦鍒楀苟缁戝畾key. - * @ queue_size 闃熷垪澶у皬 - */ -void* shmqueue_create( int * key, int queue_size); - -/** - * 缁戝畾key鍒伴槦鍒楋紝浣嗘槸骞朵笉浼氬垱寤洪槦鍒椼�傚鏋滄病鏈夊搴旀寚瀹歬ey鐨勯槦鍒楁彁绀洪敊璇苟閫�鍑� - */ -void* shmqueue_attach(int key) ; - -/** - * 閿�姣� -*/ -void shmqueue_drop(void * _shmqueue); - -/** - * 闃熷垪鍏冪礌鐨勪釜鏁� - */ -int shmqueue_size(void * _shmqueue) ; - -/** - * 鏄惁宸叉弧 - * @return 1鏄紝 0鍚� - */ -int shmqueue_full(void * _shmqueue); - -/** - * 鏄惁涓虹┖ - * @return 1鏄紝 0鍚� - */ -int shmqueue_empty(void * _shmqueue) ; - -/** - * 鍏ラ槦, 闃熷垪婊℃椂绛夊緟. - * @return 1 鍏ラ槦鎴愬姛, 0 鍏ラ槦澶辫触 - */ -int shmqueue_push(void * _shmqueue, void *src, int size); - -/** - * 鍏ラ槦, 绔嬪埢杩斿洖 - * @return 1 鍏ラ槦鎴愬姛, 0 鍏ラ槦澶辫触 - */ -int shmqueue_push_nowait(void * _shmqueue, void *src, int size) ; - -/** - * 鍏ラ槦, 鎸囧畾鏃堕棿鍐呭叆闃熶笉鎴愬姛灏辫繑鍥� - * @sec 绉� - * @nsec 绾崇 - * @return 1 鍏ラ槦鎴愬姛, 0 鍏ラ槦澶辫触 - */ -int shmqueue_push_timeout(void * _shmqueue, void *src, int size, int sec, int nsec) ; - -/** - * 鍑洪槦, 闃熷垪绌烘椂绛夊緟 - * @return 1 鍑洪槦鎴愬姛锛� 0鍑洪槦澶辫触 - */ -int shmqueue_pop(void * _shmqueue, void **dest, int *size); - -/** - * 鍑洪槦, 绔嬪埢杩斿洖 - * @return 1 鍑洪槦鎴愬姛锛� 0鍑洪槦澶辫触 - */ -int shmqueue_pop_nowait(void * _shmqueue, void **dest, int *size) ; - -/** - * 鍑洪槦, 鎸囧畾鏃堕棿鍐呭嚭闃熶笉鎴愬姛灏辫繑鍥� - * @sec绉� - * @nsec绾崇 - * @return 1 鍑洪槦鎴愬姛锛� 0鍑洪槦澶辫触 - */ -int shmqueue_pop_timeout(void * _shmqueue, void **dest, int *size, int sec, int nsec); - -/** - * 閲婃斁鍑洪槦鍒嗛厤鐨勫唴瀛� - */ -void shmqueue_free(void *ptr); - - - -#endif \ No newline at end of file diff --git a/src/shm/shm_mm_wraper.h b/src/shm/shm_mm_wraper.h deleted file mode 100644 index 0ab3a35..0000000 --- a/src/shm/shm_mm_wraper.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __SHM_MM_H__ -#define __SHM_MM_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * 鍒濆鍖栧叡浜唴瀛� - * @size 鍏变韩鍐呭瓨澶у皬, 鍗曚綅M - * - */ -void shm_mm_wrapper_init(int size); - -/** - * 閿�姣佸叡浜唴瀛� - * 鏁翠釜杩涚▼閫�鍑烘椂闇�瑕佹墽琛岃繖涓柟娉曪紝璇ユ柟娉曢鍏堜細妫�鏌ユ槸鍚﹁繕鏈夊叾浠栬繘绋嬪湪浣跨敤璇ュ叡浜唴瀛橈紝濡傛灉杩樻湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ氨鍙槸detach,濡傛灉娌℃湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ垯閿�姣佹暣鍧楀唴瀛樸�� - */ -void shm_mm_wrapper_destroy(); - -int shm_mm_wrapper_alloc_key(); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/shm/shm_mm_wrapper.cpp b/src/shm/shm_mm_wrapper.cpp index 6175923..d62602f 100644 --- a/src/shm/shm_mm_wrapper.cpp +++ b/src/shm/shm_mm_wrapper.cpp @@ -1,4 +1,4 @@ -#include "shm_mm_wraper.h" +#include "shm_mm_wrapper.h" #include "mem_pool.h" #include "hashtable.h" diff --git a/src/shm/shm_mm_wrapper.h b/src/shm/shm_mm_wrapper.h new file mode 100644 index 0000000..8ad3cf5 --- /dev/null +++ b/src/shm/shm_mm_wrapper.h @@ -0,0 +1,41 @@ +/** + * @file + * + * @brief 璐熻矗鍏变韩鍐呭瓨鐨勫垱寤轰笌閿�姣� + * + */ + +#ifndef __SHM_MM_H__ +#define __SHM_MM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 鍒涘缓骞跺垵濮嬪寲鍏变韩鍐呭瓨 + * @param size 鍏变韩鍐呭瓨澶у皬, 鍗曚綅M + * @details 鍦ㄨ繘鍏ain鏂规硶鐨勬椂鍊欐墽琛岃鏂规硶锛屾瘡涓繘绋嬪彧闇�瑕佽皟鐢ㄤ竴娆� + */ +void shm_mm_wrapper_init(int size); + +/** + * @brief 閿�姣佸叡浜唴瀛� + * @details 鏁翠釜杩涚▼閫�鍑烘椂闇�瑕佹墽琛岃繖涓柟娉曪紝璇ユ柟娉曢鍏堜細妫�鏌ユ槸鍚﹁繕鏈夊叾浠栬繘绋嬪湪浣跨敤璇ュ叡浜唴瀛橈紝濡傛灉杩樻湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ氨鍙槸detach,濡傛灉娌℃湁鍏朵粬杩涚▼鍦ㄤ娇鐢ㄥ垯閿�姣佹暣鍧楀唴瀛樸�� + */ +void shm_mm_wrapper_destroy(); + + +/** + * @brief 鍒嗛厤涓�涓猭ey缁欑敵璇疯�� + * @return key鍊� + */ +int shm_mm_wrapper_alloc_key(); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/socket/bus_server_socket_wrapper.h b/src/socket/bus_server_socket_wrapper.h index cd625dd..2a7c59d 100644 --- a/src/socket/bus_server_socket_wrapper.h +++ b/src/socket/bus_server_socket_wrapper.h @@ -1,3 +1,12 @@ +/** + * @file + * + * @brief 鎬荤嚎鏈嶅姟銆� + * + * @details 鍙戝竷璁㈤槄鏈嶅姟鐨勮矾鐢憋紝璐熻矗璁板綍璁㈤槄鑰呯殑娑堟伅骞舵妸鍙戝竷鑰呭彂甯冪殑娑堟伅杞彂缁欐劅鍏磋叮鐨勮闃呰�� + */ + + #ifndef _BUS_SERVER_SOCKET_WRAPPER_H_ #define _BUS_SERVER_SOCKET_WRAPPER_H_ @@ -7,18 +16,20 @@ extern "C" { #endif + /** - * 鍒涘缓 + * @brief 鍒涘缓 bus_server_socket + * @return bus_server_socket 鍙ユ焺 */ void * bus_server_socket_wrapper_open(); /** - * 鍏抽棴 + * @brief 閿�姣� bus_server_socket */ void bus_server_socket_wrapper_close(void *_sockt); /** - * 鍚姩bus + * @brief 鍚姩bus * * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ diff --git a/src/socket/net_mod_server_socket_wrapper.cpp b/src/socket/net_mod_server_socket_wrapper.cpp index c05832c..e1ad04d 100644 --- a/src/socket/net_mod_server_socket_wrapper.cpp +++ b/src/socket/net_mod_server_socket_wrapper.cpp @@ -3,20 +3,18 @@ void *net_mod_server_socket_open(int port) { printf("====net_mod_server_socket_open\n"); - net_mod_server_socket_t *sockt = (net_mod_server_socket_t *)malloc(sizeof(net_mod_server_socket_t)); - sockt->sockt = new NetModServerSocket(port); + NetModServerSocket *sockt = new NetModServerSocket(port); return (void *)sockt; } void net_mod_server_socket_close(void *_sockt) { printf("====net_mod_server_socket_close\n"); - net_mod_server_socket_t *sockt = (net_mod_server_socket_t *)_sockt; - delete sockt->sockt; - free(sockt); + NetModServerSocket *sockt = (NetModServerSocket *)_sockt; + delete sockt; } int net_mod_server_socket_start(void *_sockt) { - net_mod_server_socket_t *sockt = (net_mod_server_socket_t *)_sockt; - return sockt->sockt->start(); + NetModServerSocket *sockt = (NetModServerSocket *)_sockt; + return sockt->start(); } diff --git a/src/socket/net_mod_server_socket_wrapper.h b/src/socket/net_mod_server_socket_wrapper.h index 9906653..2bbda12 100644 --- a/src/socket/net_mod_server_socket_wrapper.h +++ b/src/socket/net_mod_server_socket_wrapper.h @@ -1,3 +1,11 @@ +/** + * @file + * + * @brief 缃戠粶浠g悊鏈嶅姟 + * + * @details 璐熻矗璺ㄦ満鍣ㄨ浆鍙戝彂甯冩垨璇锋眰娑堟伅 + */ + #ifndef __NET_MOD_SERVER_SOCKET_H__ #define __NET_MOD_SERVER_SOCKET_H__ @@ -6,24 +14,23 @@ #ifdef __cplusplus extern "C" { #endif - -struct net_mod_server_socket_t -{ - NetModServerSocket *sockt; -}; + /** - * 鍒涘缓 + * @brief 鍒涘缓net_mod_server_socket + * @param port 绔彛鍙� + * @return net_mod_server_socket 鍙ユ焺 */ void *net_mod_server_socket_open(int port) ; /** - * 鍏抽棴 + * @brief 閿�姣乶et_mod_server_socket */ void net_mod_server_socket_close(void *_sockt) ; /** - * 鍚姩 + * @brief 鍚姩鏈嶅姟 + * * @return 0 success, 鍏朵粬 failture */ int net_mod_server_socket_start(void *_sockt); diff --git a/src/socket/net_mod_socket.h b/src/socket/net_mod_socket.h index f3c0a54..ce45aa6 100644 --- a/src/socket/net_mod_socket.h +++ b/src/socket/net_mod_socket.h @@ -107,21 +107,34 @@ */ int force_bind( int key); + + /** - * 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅浼氫竴鐩寸瓑寰� + * @brief 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅绛夊緟timeout鐨勬椂闂村悗杩斿洖 + * * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂閫佽姹傛秷鎭紝鑺傜偣鐨勮繑鍥炰俊鎭眹鎬诲苟瀛樺偍鍦╮ecv_arr涓� * @node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴�.濡傛灉IP涓虹┖鍒欎负鏈湴鍙戦�併�� * @send_buf 鍙戦�佺殑娑堟伅锛孈send_size 璇ユ秷鎭綋鐨勯暱搴� * @recv_arr 杩斿洖鐨勫簲绛旀秷鎭粍锛孈recv_arr_size 璇ユ暟缁勯暱搴� + * @timeout 绛夊緟鏃堕棿锛屽崟浣嶆槸鍗冨垎涔嬩竴绉� * @return 鎴愬姛鍙戦�佺殑鑺傜偣鐨勪釜鏁� + * * 浼樼偣锛�1鏌愪釜鑺傜偣鐨勬晠闅滀笉浼氶樆濉炲叾浠栬妭鐐广��2 鎬ц兘濂姐�� 3 閲囩敤thread local鎶�鏈嵆淇濊瘉浜嗙嚎绋嬪畨鍏紝鍙堝彲浠ヤ娇鐢ㄨ繛鎺ユ睜缂撳瓨杩炴帴 */ int sendandrecv(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size) ; + + /** * 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅绛夊緟timeout鐨勬椂闂村悗杩斿洖 + * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂閫佽姹傛秷鎭紝鑺傜偣鐨勮繑鍥炰俊鎭眹鎬诲苟瀛樺偍鍦╮ecv_arr涓� + * @node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴�.濡傛灉IP涓虹┖鍒欎负鏈湴鍙戦�併�� + * @send_buf 鍙戦�佺殑娑堟伅锛孈send_size 璇ユ秷鎭綋鐨勯暱搴� + * @recv_arr 杩斿洖鐨勫簲绛旀秷鎭粍锛孈recv_arr_size 璇ユ暟缁勯暱搴� * @timeout 绛夊緟鏃堕棿锛屽崟浣嶆槸鍗冨垎涔嬩竴绉� - */ + * @return 鎴愬姛鍙戦�佺殑鑺傜偣鐨勪釜鏁� + * 浼樼偣锛�1鏌愪釜鑺傜偣鐨勬晠闅滀笉浼氶樆濉炲叾浠栬妭鐐广��2 鎬ц兘濂姐�� 3 閲囩敤thread local鎶�鏈嵆淇濊瘉浜嗙嚎绋嬪畨鍏紝鍙堝彲浠ヤ娇鐢ㄨ繛鎺ユ睜缂撳瓨杩炴帴 + */ int sendandrecv_timeout(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int timeout); diff --git a/src/socket/net_mod_socket_wrapper.cpp b/src/socket/net_mod_socket_wrapper.cpp index bf83e72..e9a8adf 100644 --- a/src/socket/net_mod_socket_wrapper.cpp +++ b/src/socket/net_mod_socket_wrapper.cpp @@ -8,8 +8,7 @@ */ void * net_mod_socket_open() { printf("=====net_mod_socket_open\n"); - net_mod_socket_t *sockt = (net_mod_socket_t *)malloc(sizeof(net_mod_socket_t)); - sockt->sockt = new NetModSocket; + NetModSocket *sockt = new NetModSocket; return (void *)sockt; } @@ -18,9 +17,8 @@ */ void net_mod_socket_close(void *_socket) { printf("====net_mod_socket_close\n"); - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - delete sockt->sockt; - free(sockt); + NetModSocket *sockt = (NetModSocket *)_socket; + delete sockt; } @@ -30,8 +28,8 @@ * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ int net_mod_socket_bind(void * _socket, int port){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->bind(port); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->bind(port); } /** @@ -39,8 +37,8 @@ * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ int net_mod_socket_force_bind(void * _socket, int port) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->force_bind(port); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->force_bind(port); } /** * 鍙戦�佷俊鎭� @@ -48,18 +46,18 @@ * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ int net_mod_socket_sendto(void *_socket, const void *buf, const int size, const int port) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sendto(buf, size, port); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sendto(buf, size, port); } // 鍙戦�佷俊鎭秴鏃惰繑鍥炪�� @sec 绉� 锛� @nsec 绾崇 int net_mod_socket_sendto_timeout(void *_socket, const void *buf, const int size, const int port, int sec, int nsec){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sendto_timeout(buf, size, port, sec, nsec); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sendto_timeout(buf, size, port, sec, nsec); } // 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� int net_mod_socket_sendto_nowait(void *_socket, const void *buf, const int size, const int port){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sendto_nowait(buf, size, port); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sendto_nowait(buf, size, port); } /** @@ -68,17 +66,17 @@ * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ int net_mod_socket_recvfrom(void *_socket, void **buf, int *size, int *port){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->recvfrom(buf, size, port); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->recvfrom(buf, size, port); } // 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 int net_mod_socket_recvfrom_timeout(void *_socket, void **buf, int *size, int *port, int sec, int nsec){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->recvfrom_timeout(buf, size, port, sec, nsec); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->recvfrom_timeout(buf, size, port, sec, nsec); } int net_mod_socket_recvfrom_nowait(void *_socket, void **buf, int *size, int *port){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->recvfrom_nowait(buf, size, port); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->recvfrom_nowait(buf, size, port); } @@ -93,10 +91,29 @@ * 浼樼偣锛�1鏌愪釜鑺傜偣鐨勬晠闅滀笉浼氶樆濉炲叾浠栬妭鐐广��2鎬ц兘濂� * 缂虹偣锛氫笉鏄嚎绋嬪畨鍏ㄧ殑, 鍗充笉鑳芥湁涓や釜浠ヤ笂鐨勭嚎绋嬪悓鏃朵娇鐢ㄨ繖涓璞$殑鏂规硶 */ + + +//***************************************************************************** +// +//! \brief Write one byte to special register +//! +//! This function is to write one byte to LIS302DL register,one byte will be +//! writen in appointed address. +//! +//! \param node_arr specifies the target register address. +//! \param send_buf is the data written to target register. +//! +//! \return Indicate the status of operation which can be one of the following +//! value \b SUCCESS or \b FAILURE . +//! +//! \note This function is used by internal, user MUST NOT call it in your +//! Application. +// +//***************************************************************************** int net_mod_socket_sendandrecv(void *_socket, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sendandrecv(node_arr, arrlen, send_buf, send_size, recv_arr, recv_arr_size); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sendandrecv(node_arr, arrlen, send_buf, send_size, recv_arr, recv_arr_size); } /** * 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅绛夊緟timeout鐨勬椂闂村悗杩斿洖 @@ -104,14 +121,14 @@ */ int net_mod_socket_sendandrecv_timeout(void *_socket, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int timeout){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sendandrecv_timeout(node_arr, arrlen, send_buf, send_size, recv_arr, recv_arr_size, timeout); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sendandrecv_timeout(node_arr, arrlen, send_buf, send_size, recv_arr, recv_arr_size, timeout); } int net_mod_socket_sendandrecv_nowait(void *_socket, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sendandrecv_nowait(node_arr, arrlen, send_buf, send_size, recv_arr, recv_arr_size); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sendandrecv_nowait(node_arr, arrlen, send_buf, send_size, recv_arr, recv_arr_size); } @@ -124,16 +141,16 @@ * @return 鎴愬姛鍙戝竷鐨勮妭鐐圭殑涓暟 */ int net_mod_socket_pub(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->pub(node_arr, node_arr_len, topic, topic_size, content, content_size); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->pub(node_arr, node_arr_len, topic, topic_size, content, content_size); } int net_mod_socket_pub_timeout(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int msec){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->pub_timeout(node_arr, node_arr_len, topic, topic_size, content, content_size, msec); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->pub_timeout(node_arr, node_arr_len, topic, topic_size, content, content_size, msec); } int net_mod_socket_pub_nowait(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->pub_nowait(node_arr, node_arr_len, topic, topic_size, content, content_size); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->pub_nowait(node_arr, node_arr_len, topic, topic_size, content, content_size); } @@ -147,17 +164,17 @@ * @port 鎬荤嚎绔彛 */ int net_mod_socket_sub(void * _socket, void *topic, int size) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sub((char *)topic, size, SHM_BUS_KEY); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sub((char *)topic, size, SHM_BUS_KEY); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int sec, int nsec){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sub_timeout((char *)topic, size, SHM_BUS_KEY, sec, nsec); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sub_timeout((char *)topic, size, SHM_BUS_KEY, sec, nsec); } int net_mod_socket_sub_nowait(void * _socket, void *topic, int size){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sub_nowait((char *)topic, size, SHM_BUS_KEY); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->sub_nowait((char *)topic, size, SHM_BUS_KEY); } @@ -168,17 +185,17 @@ * @port 鎬荤嚎绔彛 */ int net_mod_socket_desub(void * _socket, void *topic, int size) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->desub((char *)topic, size, SHM_BUS_KEY); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->desub((char *)topic, size, SHM_BUS_KEY); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 int net_mod_socket_desub_timeout(void * _socket, void *topic, int size, int sec, int nsec) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->desub_timeout((char *)topic, size, SHM_BUS_KEY, sec, nsec); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->desub_timeout((char *)topic, size, SHM_BUS_KEY, sec, nsec); } int net_mod_socket_desub_nowait(void * _socket, void *topic, int size){ - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->desub_nowait((char *)topic, size, SHM_BUS_KEY); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->desub_nowait((char *)topic, size, SHM_BUS_KEY); } @@ -187,8 +204,8 @@ * 鑾峰彇soket绔彛鍙� */ int net_mod_socket_get_key(void * _socket) { - net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->get_key(); + NetModSocket *sockt = (NetModSocket *)_socket; + return sockt->get_key(); } diff --git a/src/socket/net_mod_socket_wrapper.h b/src/socket/net_mod_socket_wrapper.h index 80195fa..171a3a8 100644 --- a/src/socket/net_mod_socket_wrapper.h +++ b/src/socket/net_mod_socket_wrapper.h @@ -1,3 +1,13 @@ +/** + * @file + * + * @brief 鍙戝竷璁㈤槄鍜岃姹傚簲绛旂殑瀹㈡埛绔� + * + * @details 鍚態usService鍙戝竷娑堟伅鎴栬�呭湪BusService涓婅闃呮劅鍏磋叮鐨勬秷鎭� + */ + + + #ifndef __NET_MOD_SOCKET_H__ #define __NET_MOD_SOCKET_H__ @@ -7,173 +17,311 @@ extern "C" { #endif -struct net_mod_socket_t -{ - NetModSocket *sockt; -}; + -/************************************************ - * 鍒涘缓 net_mod_socket - ***********************************************/ +/** + * @brief 鍒涘缓 net_mod_socket + * @return net_mod_socket 鍙ユ焺 + */ void * net_mod_socket_open(); -/************************************************ - * 鍏抽棴 net_mod_socket - ***********************************************/ +/** + * @brief 鍏抽棴 net_mod_socket + */ void net_mod_socket_close(void *_sockt); -/************************************************ - * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -***********************************************/ +/** + * @brief 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� + * + * @param key 缁戝畾鐨刱ey鍊� + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_bind(void * _socket, int key); -/************************************************ - * 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -***********************************************/ +/** + * @brief 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key + * + * @return 0鏄垚鍔燂紝 鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_force_bind(void * _socket, int key); -/************************************************ - * 鍙戦�佷俊鎭�,鍙戦�佸畬鎴愭墠杩斿洖 - * @key 鍙戦�佺粰璋� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 - ***********************************************/ +/** + * @brief 鍙戦�佷俊鎭�,鍙戦�佸畬鎴愭墠杩斿洖 + * + * @param buf 娑堟伅瀛樻斁鐨勭紦瀛樺湴鍧� + * @param size 娑堟伅闀垮害 + * @param param key 鍙戦�佺粰璋� + * + * @return 0鏄垚鍔燂紝 鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_sendto(void *_socket, const void *buf, const int size, const int key); -/************************************************ - * 鍙戦�佷俊鎭紝 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 - ***********************************************/ + +/** + * @brief 鍙戦�佷俊鎭紝鍦ㄦ寚瀹氭椂闂村唴娌″彂閫佸畬鎴愪篃杩斿洖銆� + * + * @param buf 娑堟伅瀛樻斁鐨勭紦瀛樺湴鍧� + * @param size 娑堟伅闀垮害 + * @param param key 鍙戦�佺粰璋� + * @param sec 绉� + * @param nsec 绾崇 + * + * @return 0鏄垚鍔燂紝 鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_sendto_timeout(void *_socket, const void *buf, const int size, const int key, int sec, int nsec); -/************************************************ - * 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� - ***********************************************/ + +/** + * @brief 鍙戦�佷俊鎭紝鏃犺鏄惁鍙戦�佸畬鎴愮珛鍒昏繑鍥炪�� + * + * @param buf 娑堟伅瀛樻斁鐨勭紦瀛樺湴鍧� + * @param size 娑堟伅闀垮害 + * @param param key 鍙戦�佺粰璋� + * + * @return 0鏄垚鍔燂紝 鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_sendto_nowait(void *_socket, const void *buf, const int size, const int key); -/************************************************ - * 鎺ユ敹淇℃伅 - * @key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -***********************************************/ +/** + * @brief 绛夊緟鎺ユ敹淇℃伅锛岀洿鍒版湁娑堟伅鎺ュ彈鍒版墠杩斿洖 + * + * @param buf 鎺ュ彈鍒扮殑娑堟伅瀛樻斁鐨勭紦瀛樺湴鍧�锛岃buf浣跨敤瀹屾垚鍚庨渶瑕佹墜鍔ㄩ噴鏀� + * @param size 鎺ュ彈鍒版秷鎭殑闀垮害 + * @param key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * + * @return 0鏄垚鍔燂紝 鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_recvfrom(void *_socket, void **buf, int *size, int *key); -// 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 +/** + * @brief 绛夊緟鎺ユ敹淇℃伅锛屽湪鎸囧畾鐨勬椂闂村唴鍗充娇娌℃湁鎺ュ彈鍒版秷鎭篃瑕佽繑鍥� + * + * @param buf 鎺ュ彈鍒扮殑娑堟伅瀛樻斁鐨勭紦瀛樺湴鍧�锛岃buf浣跨敤瀹屾垚鍚庨渶瑕佹墜鍔ㄩ噴鏀� + * @param size 鎺ュ彈鍒版秷鎭殑闀垮害 + * @param key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * @param sec 绉� + * @param nsec 绾崇 + * + * @return 0鏄垚鍔燂紝 鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_recvfrom_timeout(void *_socket, void **buf, int *size, int *key, int sec, int nsec); + +/** + * @brief 绛夊緟鎺ユ敹淇℃伅锛岀洿鍒版湁娑堟伅鎺ュ彈鍒版墠杩斿洖 + * + * @param buf 鎺ュ彈鍒扮殑娑堟伅瀛樻斁鐨勭紦瀛樺湴鍧�锛岃buf浣跨敤瀹屾垚鍚庨渶瑕佹墜鍔ㄩ噴鏀� + * @param size 鎺ュ彈鍒版秷鎭殑闀垮害 + * @param key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_recvfrom_nowait(void *_socket, void **buf, int *size, int *key); -/************************************************ - * 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅浼氫竴鐩寸瓑寰� +/** + * @brief 璺ㄦ満鍣ㄥ彂閫佹秷鎭苟鎺ュ彈杩斿洖鐨勫簲绛旀秷鎭紝鐩村埌鍙戦�佸畬鎴愭墠杩斿洖 + * * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂閫佽姹傛秷鎭紝鑺傜偣鐨勮繑鍥炰俊鎭眹鎬诲苟瀛樺偍鍦╮ecv_arr涓� - * @node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴�.濡傛灉IP涓虹┖鍒欎负鏈湴鍙戦�併�� - * @send_buf 鍙戦�佺殑娑堟伅锛孈send_size 璇ユ秷鎭綋鐨勯暱搴� - * @recv_arr 杩斿洖鐨勫簲绛旀秷鎭粍锛孈recv_arr_size 璇ユ暟缁勯暱搴� + * @param node_arr 缃戠粶鑺傜偣缁�, + * @param node_arr_len璇ユ暟缁勯暱搴�.濡傛灉IP涓虹┖鍒欎负鏈湴鍙戦�併�� + * @param send_buf 鍙戦�佺殑娑堟伅 + * @param send_size 璇ユ秷鎭綋鐨勯暱搴� + * @param recv_arr 杩斿洖鐨勫簲绛旀秷鎭暟缁� + * @param recv_arr_size 杩斿洖鐨勫簲绛旀秷鎭暟缁勯暱搴� + * * @return 鎴愬姛鍙戦�佺殑鑺傜偣鐨勪釜鏁� - * 浼樼偣锛�1鏌愪釜鑺傜偣鐨勬晠闅滀笉浼氶樆濉炲叾浠栬妭鐐广��2 鎬ц兘濂姐�� 3 閲囩敤thread local鎶�鏈嵆淇濊瘉浜嗙嚎绋嬪畨鍏紝鍙堝彲浠ヤ娇鐢ㄨ繛鎺ユ睜缂撳瓨杩炴帴 - ***********************************************/ -int net_mod_socket_sendandrecv(void *_sockt, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, + * + */ +extern int net_mod_socket_sendandrecv(void *_sockt, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size) ; -/************************************************ - * 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅绛夊緟timeout鐨勬椂闂村悗杩斿洖 - * @timeout 绛夊緟鏃堕棿锛屽崟浣嶆槸鍗冨垎涔嬩竴绉� - ***********************************************/ + + +/** + * @brief 璺ㄦ満鍣ㄥ彂閫佹秷鎭苟鎺ュ彈杩斿洖鐨勫簲绛旀秷鎭紝鍦ㄦ寚瀹氭椂闂村唴鍗充娇娌℃湁鍙戦�佸畬鎴愪篃杩斿洖 + * + * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂閫佽姹傛秷鎭紝鑺傜偣鐨勮繑鍥炰俊鎭眹鎬诲苟瀛樺偍鍦╮ecv_arr涓� + * @param node_arr 缃戠粶鑺傜偣缁�, + * @param node_arr_len璇ユ暟缁勯暱搴�.濡傛灉IP涓虹┖鍒欎负鏈湴鍙戦�併�� + * @param send_buf 鍙戦�佺殑娑堟伅 + * @param send_size 璇ユ秷鎭綋鐨勯暱搴� + * @param recv_arr 杩斿洖鐨勫簲绛旀秷鎭暟缁� + * @param recv_arr_size 杩斿洖鐨勫簲绛旀秷鎭暟缁勯暱搴� + * @param timeout 绛夊緟鏃堕棿(璞锛屽嵆鍗冨垎涔嬩竴绉�) + * + * @return 鎴愬姛鍙戦�佺殑鑺傜偣鐨勪釜鏁� + * + */ int net_mod_socket_sendandrecv_timeout(void *_sockt, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int timeout); -/************************************************ - * 涓嶇瓑寰呯珛鍗宠繑鍥� - ***********************************************/ + +/** + * @brief 璺ㄦ満鍣ㄥ彂閫佹秷鎭苟鎺ュ彈杩斿洖鐨勫簲绛旀秷鎭紝涓嶇鏄惁鍙戦�佸畬鎴愮珛鍒昏繑鍥� + * + * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂閫佽姹傛秷鎭紝鑺傜偣鐨勮繑鍥炰俊鎭眹鎬诲苟瀛樺偍鍦╮ecv_arr涓� + * @param node_arr 缃戠粶鑺傜偣缁�, + * @param node_arr_len璇ユ暟缁勯暱搴�.濡傛灉IP涓虹┖鍒欎负鏈湴鍙戦�併�� + * @param send_buf 鍙戦�佺殑娑堟伅 + * @param send_size 璇ユ秷鎭綋鐨勯暱搴� + * @param recv_arr 杩斿洖鐨勫簲绛旀秷鎭暟缁� + * @param recv_arr_size 杩斿洖鐨勫簲绛旀秷鎭暟缁勯暱搴� + * + * @return 鎴愬姛鍙戦�佺殑鑺傜偣鐨勪釜鏁� + * + */ int net_mod_socket_sendandrecv_nowait(void *_sockt, net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** recv_arr, int *recv_arr_size) ; - /************************************************ - * 鍚憂ode_arr 涓殑鎵�鏈夌綉缁滆妭鐐瑰彂甯冩秷鎭� - * @node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴� - * @topic 涓婚锛孈topic_size 璇ヤ富棰樼殑闀垮害 - * @content 鍐呭锛孈content_size 鍐呭闀垮害 - * @return 鎴愬姛鍙戝竷鐨勮妭鐐圭殑涓暟 - ***********************************************/ + /** + * @brief 鍚憂ode_arr涓殑鎵�鏈夌綉缁滆妭鐐瑰彂甯冩秷鎭� + * + * @param node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴� + * @param topic 涓婚锛� + * @param topic_size 璇ヤ富棰樼殑闀垮害 + * @param content 鍐呭锛� + * @param 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); -/************************************************ - * 鍙戝竷娑堟伅瓒呮椂鍚庤繑鍥� - * @msec 姣锛堝崈鍒嗕箣涓�绉掞級 - ***********************************************/ + + +/** + * @brief 鍚憂ode_arr涓殑鎵�鏈夌綉缁滆妭鐐瑰彂甯冩秷鎭紝鍦ㄦ寚瀹氭椂闂村唴鍗充娇娌℃湁鍙戝竷瀹屾垚涔熻繑鍥� + * + * @param node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴� + * @param topic 涓婚锛� + * @param topic_size 璇ヤ富棰樼殑闀垮害 + * @param content 鍐呭锛� + * @param content_size 鍐呭闀垮害 + * @param msec 瓒呮椂鏃堕棿锛堟绉掞紝鏃㈠崈鍒嗕箣涓�绉掞級 + * + * @return 鎴愬姛鍙戝竷鐨勮妭鐐圭殑涓暟 + */ int net_mod_socket_pub_timeout(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int msec); -/************************************************ - * 鍙戝竷娑堟伅涓嶇鎴愬姛涓庡惁绔嬪埢杩斿洖 - * @msec 姣锛堝崈鍒嗕箣涓�绉掞級 - ***********************************************/ + + +/** + * @brief 鍚憂ode_arr涓殑鎵�鏈夌綉缁滆妭鐐瑰彂甯冩秷鎭紝涓嶇鏄惁鍙戝竷瀹屾垚绔嬪埢杩斿洖 + * + * @param node_arr 缃戠粶鑺傜偣缁�, @node_arr_len璇ユ暟缁勯暱搴� + * @param topic 涓婚锛� + * @param topic_size 璇ヤ富棰樼殑闀垮害 + * @param content 鍐呭锛� + * @param content_size 鍐呭闀垮害 + * + * @return 鎴愬姛鍙戝竷鐨勮妭鐐圭殑涓暟 + */ int net_mod_socket_pub_nowait(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size); -/************************************************ - * 璁㈤槄鎸囧畾涓婚 - * @topic 涓婚 - * @size 涓婚闀垮害 - * @key 鎬荤嚎绔彛 - ***********************************************/ -int net_mod_socket_sub(void * _socket, void *topic, int size); -/************************************************ - * 璁㈤槄娑堟伅锛岃秴鏃惰繑鍥炪�� - * @sec 绉� 锛� @nsec 绾崇 - ***********************************************/ -int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int sec, int nsec); -/************************************************ - * 璁㈤槄娑堟伅锛屼笉绠℃垚鍔熶笌鍚︾珛鍒昏繑鍥炪�� +/** + * @brief 璁㈤槄鎰熷叴瓒d富棰樼殑娑堟伅 * - ***********************************************/ + * @param topic 涓婚 + * @param size 涓婚闀垮害 + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + * + */ +int net_mod_socket_sub(void * _socket, void *topic, int size); + +/** + * @brief 璁㈤槄鎰熷叴瓒d富棰樼殑娑堟伅, 鍦ㄦ寚瀹氱殑鏃堕棿鍐呭嵆浣挎湭瀹屾垚璁㈤槄涔熻繑鍥� + * + * @param topic 涓婚 + * @param size 涓婚闀垮害 + * @param sec 绉� + * @param nsec 绾崇 + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ +int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int sec, int nsec); + + +/** + * @brief 璁㈤槄鎰熷叴瓒d富棰樼殑娑堟伅锛屼笉绠℃槸鍚﹀畬鎴愯闃呯珛鍒昏繑鍥� + * + * @param topic 涓婚 + * @param size 涓婚闀垮害 + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + * + */ int net_mod_socket_sub_nowait(void * _socket, void *topic, int size); -/************************************************ - * 鍙栨秷璁㈤槄鎸囧畾涓婚 - * @topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� - * @size 涓婚闀垮害 - * @key 鎬荤嚎绔彛 - ***********************************************/ +/** + * @brief 鍙栨秷璁㈤槄鎸囧畾涓婚 + * + * @param topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� + * @param size 涓婚闀垮害 + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_desub(void * _socket, void *topic, int size); -/************************************************ - * 鍙栨秷璁㈤槄鎸囧畾涓婚 瓒呮椂杩斿洖銆� - * @sec 绉� 锛� @nsec 绾崇 - ***********************************************/ + + +/** + * @brief 鍙栨秷璁㈤槄鎸囧畾涓婚锛屽湪鎸囧畾鏃堕棿鍐呭嵆浣挎湭瀹屾垚鍙栨秷璁㈤槄浠诲姟涔熻繑鍥� + * + * @param topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� + * @param size 涓婚闀垮害 + * @param sec 绉� + * @param nsec 绾崇 + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_desub_timeout(void * _socket, void *topic, int size, int sec, int nsec); -/************************************************ - * 鍙栨秷璁㈤槄鎸囧畾涓婚 涓嶇鎴愬姛涓庡惁绔嬪埢杩斿洖銆� - ***********************************************/ + + +/** + * @brief 鍙栨秷璁㈤槄鎸囧畾涓婚锛屼笉绠℃槸鍚﹀畬鎴愬彇娑堣闃呬换鍔¢兘瑕佺珛鍒昏繑鍥� + * + * @param topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� + * @param size 涓婚闀垮害 + * + * @return 0鏄垚鍔燂紝鍏朵粬鍊兼槸澶辫触鐨勯敊璇爜 + */ int net_mod_socket_desub_nowait(void * _socket, void *topic, int size); -/************************************************ - * 鑾峰彇soket绔彛鍙� - ***********************************************/ +/** + * @brief 鑾峰彇soket鐨刱ey + * @return key + */ int net_mod_socket_get_key(void * _socket) ; -/************************************************ - * 閿�姣乻endandrecv鏂规硶杩斿洖鐨勬秷鎭粍 - * @arr 娑堟伅缁� - * @size 娑堟伅缁勭殑闀垮害 - ***********************************************/ +/** + * @brief 閿�姣乻endandrecv鏂规硶杩斿洖鐨勬秷鎭粍 + * + * @param arr 娑堟伅缁� + * @param size 娑堟伅缁勭殑闀垮害 + */ void net_mod_socket_free_recv_msg_arr(net_mod_recv_msg_t * arr, int size); -/************************************************ - * 閲婃斁瀛樺偍鎺ユ敹淇℃伅鐨刡uf - ***********************************************/ +/** + * @brief 閲婃斁瀛樺偍鎺ユ敹淇℃伅鐨刡uf + */ void net_mod_socket_free(void *buf) ; -/************************************************ - * 鍒犻櫎key瀵瑰簲鐨勫叡浜槦鍒楋紝骞跺湪bus閲屽垹闄よkey鐨勮闃� - ***********************************************/ +/** + * @brief 鍒犻櫎key瀵瑰簲鐨勫叡浜槦鍒楋紝骞跺湪bus閲屽垹闄よkey鐨勮闃� + * + * @return 鍒犻櫎鐨刱ey鐨勬暟閲� + */ int shm_mod_socket_remove_key(int key); -/************************************************ - * 鎵归噺鍒犻櫎key瀵瑰簲鐨勫叡浜槦鍒楋紝骞跺湪bus閲屽垹闄よkey鐨勮闃� - ***********************************************/ +/** + * @brief 鎵归噺鍒犻櫎key瀵瑰簲鐨勫叡浜槦鍒楋紝骞跺湪bus閲屽垹闄よkey鐨勮闃� + * + * @return 鍒犻櫎鐨刱ey鐨勬暟閲� + */ int shm_mod_socket_remove_keys(int keys[], int length); #ifdef __cplusplus -- Gitblit v1.8.0