From 973ea7eaee914ba2e296d97bdb0457b6732891e1 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期五, 27 十一月 2020 18:55:58 +0800 Subject: [PATCH] update --- src/socket/net_mod_socket.c | 92 +++++++------- src/socket/net_mod_socket_wrapper.h | 34 ++-- src/socket/dgram_mod_socket.h | 52 ++++---- src/socket/net_mod_socket.h | 52 ++++---- src/socket/dgram_mod_socket.c | 94 +++++++------- lib/libusgcommon.so | 0 src/socket/net_mod_server_socket.c | 5 7 files changed, 165 insertions(+), 164 deletions(-) diff --git a/lib/libusgcommon.so b/lib/libusgcommon.so new file mode 100644 index 0000000..4f1646b --- /dev/null +++ b/lib/libusgcommon.so Binary files differ diff --git a/src/socket/dgram_mod_socket.c b/src/socket/dgram_mod_socket.c index 1667bf6..cd560b2 100644 --- a/src/socket/dgram_mod_socket.c +++ b/src/socket/dgram_mod_socket.c @@ -41,81 +41,81 @@ * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_bind(void * _socket, int port) { +int dgram_mod_bind(void * _socket, int key) { dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->bind(port); + return socket->m_socket->bind(key); } /** * 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_force_bind(void * _socket, int port) { +int dgram_mod_force_bind(void * _socket, int key) { dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->force_bind(port); + return socket->m_socket->force_bind(key); } /** * 鍙戦�佷俊鎭� - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_sendto(void *_socket, const void *buf, const int size, const int port){ +int dgram_mod_sendto(void *_socket, const void *buf, const int size, const int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->sendto(buf, size,port); + return socket->m_socket->sendto(buf, size,key); } // 鍙戦�佷俊鎭秴鏃惰繑鍥炪�� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_sendto_timeout(void *_socket, const void *buf, const int size, const int port, int sec, int nsec){ +int dgram_mod_sendto_timeout(void *_socket, const void *buf, const int size, const int key, int sec, int nsec){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; struct timespec timeout = {sec, nsec}; - return socket->m_socket->sendto_timeout(buf, size, port, &timeout); + return socket->m_socket->sendto_timeout(buf, size, key, &timeout); } // 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� -int dgram_mod_sendto_nowait(void *_socket, const void *buf, const int size, const int port){ +int dgram_mod_sendto_nowait(void *_socket, const void *buf, const int size, const int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->sendto_nowait(buf, size,port); + return socket->m_socket->sendto_nowait(buf, size,key); } /** * 鎺ユ敹淇℃伅 - * @port 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * @key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_recvfrom(void *_socket, void **buf, int *size, int *port) { +int dgram_mod_recvfrom(void *_socket, void **buf, int *size, int *key) { dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->recvfrom(buf, size, port); + return socket->m_socket->recvfrom(buf, size, key); } // 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_recvfrom_timeout(void *_socket, void **buf, int *size, int *port, int sec, int nsec){ +int dgram_mod_recvfrom_timeout(void *_socket, void **buf, int *size, int *key, int sec, int nsec){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; struct timespec timeout = {sec, nsec}; - return socket->m_socket->recvfrom_timeout(buf, size, port, &timeout); + return socket->m_socket->recvfrom_timeout(buf, size, key, &timeout); } -int dgram_mod_recvfrom_nowait(void *_socket, void **buf, int *size, int *port){ +int dgram_mod_recvfrom_nowait(void *_socket, void **buf, int *size, int *key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->recvfrom_nowait(buf, size, port); + return socket->m_socket->recvfrom_nowait(buf, size, key); } /** * 鍙戦�佽姹備俊鎭苟绛夊緟鎺ユ敹搴旂瓟 - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @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){ +int dgram_mod_sendandrecv(void * _socket, const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->sendandrecv(send_buf, send_size, port, recv_buf, recv_size); + return socket->m_socket->sendandrecv(send_buf, send_size, key, recv_buf, recv_size); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_sendandrecv_timeout(void * _socket, const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size, int sec, int nsec){ +int dgram_mod_sendandrecv_timeout(void * _socket, const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size, int sec, int nsec){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; struct timespec timeout = {sec, nsec}; - return socket->m_socket->sendandrecv_timeout(send_buf, send_size, port, recv_buf, recv_size, &timeout); + return socket->m_socket->sendandrecv_timeout(send_buf, send_size, key, recv_buf, recv_size, &timeout); } -int dgram_mod_sendandrecv_nowait(void * _socket, const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size) { +int dgram_mod_sendandrecv_nowait(void * _socket, const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size) { dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->sendandrecv_nowait(send_buf, send_size, port, recv_buf, recv_size); + return socket->m_socket->sendandrecv_nowait(send_buf, send_size, key, recv_buf, recv_size); } @@ -133,21 +133,21 @@ * 璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int dgram_mod_sub(void * _socket, void *topic, int size, int port){ +int dgram_mod_sub(void * _socket, void *topic, int size, int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->sub((char *)topic, size, port); + return socket->m_socket->sub((char *)topic, size, key); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_sub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec){ +int dgram_mod_sub_timeout(void * _socket, void *topic, int size, int key, int sec, int nsec){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; struct timespec timeout = {sec, nsec}; - return socket->m_socket->sub_timeout((char *)topic, size, port, &timeout); + return socket->m_socket->sub_timeout((char *)topic, size, key, &timeout); } -int dgram_mod_sub_nowait(void * _socket, void *topic, int size, int port){ +int dgram_mod_sub_nowait(void * _socket, void *topic, int size, int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->sub_nowait((char *)topic, size, port); + return socket->m_socket->sub_nowait((char *)topic, size, key); } @@ -156,21 +156,21 @@ * 鍙栨秷璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int dgram_mod_desub(void * _socket, void *topic, int size, int port){ +int dgram_mod_desub(void * _socket, void *topic, int size, int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->desub((char *)topic, size, port); + return socket->m_socket->desub((char *)topic, size, key); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_desub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec){ +int dgram_mod_desub_timeout(void * _socket, void *topic, int size, int key, int sec, int nsec){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; struct timespec timeout = {sec, nsec}; - return socket->m_socket->desub_timeout((char *)topic, size, port, &timeout); + return socket->m_socket->desub_timeout((char *)topic, size, key, &timeout); } -int dgram_mod_desub_nowait(void * _socket, void *topic, int size, int port){ +int dgram_mod_desub_nowait(void * _socket, void *topic, int size, int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->desub_nowait((char *)topic, size, port); + return socket->m_socket->desub_nowait((char *)topic, size, key); } @@ -179,26 +179,26 @@ * 鍙戝竷涓婚 * @topic 涓婚 * @content 涓婚鍐呭 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int dgram_mod_pub(void * _socket, void *topic, int topic_size, void *content, int content_size, int port){ +int dgram_mod_pub(void * _socket, void *topic, int topic_size, void *content, int content_size, int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->pub((char *)topic, topic_size, content, content_size, port); + return socket->m_socket->pub((char *)topic, topic_size, content, content_size, key); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_pub_timeout(void * _socket, void *topic, int topic_size, void *content, int content_size, int port, int sec, int nsec){ +int dgram_mod_pub_timeout(void * _socket, void *topic, int topic_size, void *content, int content_size, int key, int sec, int nsec){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; struct timespec timeout = {sec, nsec}; - return socket->m_socket->pub_timeout((char *)topic, topic_size, content, content_size, port, &timeout); + return socket->m_socket->pub_timeout((char *)topic, topic_size, content, content_size, key, &timeout); } -int dgram_mod_pub_nowait(void * _socket, void *topic, int topic_size, void *content, int content_size, int port){ +int dgram_mod_pub_nowait(void * _socket, void *topic, int topic_size, void *content, int content_size, int key){ dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; - return socket->m_socket->pub_nowait((char *)topic, topic_size, content, content_size, port); + return socket->m_socket->pub_nowait((char *)topic, topic_size, content, content_size, key); } /** - * 鑾峰彇soket绔彛鍙� + * 鑾峰彇soket key */ int dgram_mod_get_port(void * _socket) { dgram_mod_socket_t * socket = (dgram_mod_socket_t *) _socket; diff --git a/src/socket/dgram_mod_socket.h b/src/socket/dgram_mod_socket.h index 2ea3348..22fbe85 100644 --- a/src/socket/dgram_mod_socket.h +++ b/src/socket/dgram_mod_socket.h @@ -33,43 +33,43 @@ * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_bind(void * _socket, int port); +int dgram_mod_bind(void * _socket, int key); /** * 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_force_bind(void * _socket, int port); +int dgram_mod_force_bind(void * _socket, int key); /** * 鍙戦�佷俊鎭� - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_sendto(void *_socket, const void *buf, const int size, const int port); +int dgram_mod_sendto(void *_socket, const void *buf, const int size, const int key); // 鍙戦�佷俊鎭秴鏃惰繑鍥炪�� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_sendto_timeout(void *_socket, const void *buf, const int size, const int port, int sec, int nsec); +int dgram_mod_sendto_timeout(void *_socket, const void *buf, const int size, const int key, int sec, int nsec); // 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� -int dgram_mod_sendto_nowait(void *_socket, const void *buf, const int size, const int port); +int dgram_mod_sendto_nowait(void *_socket, const void *buf, const int size, const int key); /** * 鎺ユ敹淇℃伅 - * @port 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * @key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_recvfrom(void *_socket, void **buf, int *size, int *port); +int dgram_mod_recvfrom(void *_socket, void **buf, int *size, int *key); // 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_recvfrom_timeout(void *_socket, void **buf, int *size, int *port, int sec, int nsec); -int dgram_mod_recvfrom_nowait(void *_socket, void **buf, int *size, int *port); +int dgram_mod_recvfrom_timeout(void *_socket, void **buf, int *size, int *key, int sec, int nsec); +int dgram_mod_recvfrom_nowait(void *_socket, void **buf, int *size, int *key); /** * 鍙戦�佽姹備俊鎭苟绛夊緟鎺ユ敹搴旂瓟 - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int dgram_mod_sendandrecv(void * _socket, const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size) ; +int dgram_mod_sendandrecv(void * _socket, const void *send_buf, const int send_size, const int send_key, void **recv_buf, int *recv_size) ; // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_sendandrecv_timeout(void * _socket, const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size, int sec, int nsec) ; -int dgram_mod_sendandrecv_nowait(void * _socket, const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size) ; +int dgram_mod_sendandrecv_timeout(void * _socket, const void *send_buf, const int send_size, const int send_key, void **recv_buf, int *recv_size, int sec, int nsec) ; +int dgram_mod_sendandrecv_nowait(void * _socket, const void *send_buf, const int send_size, const int send_key, void **recv_buf, int *recv_size) ; /** @@ -83,35 +83,35 @@ * 璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int dgram_mod_sub(void * _socket, void *topic, int size, int port); +int dgram_mod_sub(void * _socket, void *topic, int size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_sub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec); -int dgram_mod_sub_nowait(void * _socket, void *topic, int size, int port); +int dgram_mod_sub_timeout(void * _socket, void *topic, int size, int key, int sec, int nsec); +int dgram_mod_sub_nowait(void * _socket, void *topic, int size, int key); /** * 鍙栨秷璁㈤槄鎸囧畾涓婚 * @topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int dgram_mod_desub(void * _socket, void *topic, int size, int port); +int dgram_mod_desub(void * _socket, void *topic, int size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_desub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec); -int dgram_mod_desub_nowait(void * _socket, void *topic, int size, int port); +int dgram_mod_desub_timeout(void * _socket, void *topic, int size, int key, int sec, int nsec); +int dgram_mod_desub_nowait(void * _socket, void *topic, int size, int key); /** * 鍙戝竷涓婚 * @topic 涓婚 * @content 涓婚鍐呭 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int dgram_mod_pub(void * _socket, void *topic, int topic_size, void *content, int content_size, int port); +int dgram_mod_pub(void * _socket, void *topic, int topic_size, void *content, int content_size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int dgram_mod_pub_timeout(void * _socket, void *topic, int topic_size, void *content, int content_size, int port, int sec, int nsec); -int dgram_mod_pub_nowait(void * _socket, void *topic, int topic_size, void *content, int content_size, int port); +int dgram_mod_pub_timeout(void * _socket, void *topic, int topic_size, void *content, int content_size, int key, int sec, int nsec); +int dgram_mod_pub_nowait(void * _socket, void *topic, int topic_size, void *content, int content_size, int key); /** diff --git a/src/socket/net_mod_server_socket.c b/src/socket/net_mod_server_socket.c index 6413fe7..bc5923a 100644 --- a/src/socket/net_mod_server_socket.c +++ b/src/socket/net_mod_server_socket.c @@ -4,6 +4,8 @@ #include "net_mod_socket_io.h" #include "net_mod_socket.h" +static Logger * logger = LoggerFactory::getLogger(); + NetModServerSocket::NetModServerSocket(int _port): listenfd(0), port(_port), max_buf(1024), max_topic_buf(256), max_response_buf(1024) { @@ -190,6 +192,7 @@ } else if(request_head.mod == BUS) { + // TODO: pub response if(request_head.topic_length > max_topic_buf) { if( (topic_buf = realloc(topic_buf, request_head.topic_length)) == NULL ) { LoggerFactory::getLogger()->error(errno, "NetModServerSocket::process_client realloc topic_buf"); @@ -214,8 +217,6 @@ void NetModServerSocket::check_clients() { int i, connfd; - //rio_t *rio; - Logger * logger = LoggerFactory::getLogger(); for (i = 0; (i <= pool.maxi) && (pool.nready > 0); i++) { diff --git a/src/socket/net_mod_socket.c b/src/socket/net_mod_socket.c index bc40442..5ddf221 100644 --- a/src/socket/net_mod_socket.c +++ b/src/socket/net_mod_socket.c @@ -28,16 +28,16 @@ * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int NetModSocket::bind(int port) { - return shmModSocket.bind(port); +int NetModSocket::bind(int key) { + return shmModSocket.bind(key); } /** * 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int NetModSocket::force_bind( int port) { - return shmModSocket.force_bind(port); +int NetModSocket::force_bind( int key) { + return shmModSocket.force_bind(key); } int NetModSocket::sendandrecv(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, @@ -373,57 +373,57 @@ /** * 鍙戦�佷俊鎭� - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int NetModSocket::sendto(const void *buf, const int size, const int port){ - return shmModSocket.sendto(buf, size,port); +int NetModSocket::sendto(const void *buf, const int size, const int key){ + return shmModSocket.sendto(buf, size, key); } // 鍙戦�佷俊鎭秴鏃惰繑鍥炪�� @sec 绉� 锛� @nsec 绾崇 -int NetModSocket::sendto_timeout(const void *buf, const int size, const int port, int sec, int nsec){ +int NetModSocket::sendto_timeout(const void *buf, const int size, const int key, int sec, int nsec){ struct timespec timeout = {sec, nsec}; - return shmModSocket.sendto_timeout(buf, size, port, &timeout); + return shmModSocket.sendto_timeout(buf, size, key, &timeout); } // 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� -int NetModSocket::sendto_nowait(const void *buf, const int size, const int port){ - return shmModSocket.sendto_nowait(buf, size,port); +int NetModSocket::sendto_nowait(const void *buf, const int size, const int key){ + return shmModSocket.sendto_nowait(buf, size, key); } /** * 鎺ユ敹淇℃伅 - * @port 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * @key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int NetModSocket::recvfrom(void **buf, int *size, int *port) { - return shmModSocket.recvfrom(buf, size, port); +int NetModSocket::recvfrom(void **buf, int *size, int *key) { + return shmModSocket.recvfrom(buf, size, key); } // 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int NetModSocket::recvfrom_timeout(void **buf, int *size, int *port, int sec, int nsec){ +int NetModSocket::recvfrom_timeout(void **buf, int *size, int *key, int sec, int nsec){ struct timespec timeout = {sec, nsec}; - return shmModSocket.recvfrom_timeout(buf, size, port, &timeout); + return shmModSocket.recvfrom_timeout(buf, size, key, &timeout); } -int NetModSocket::recvfrom_nowait(void **buf, int *size, int *port){ - return shmModSocket.recvfrom_nowait(buf, size, port); +int NetModSocket::recvfrom_nowait(void **buf, int *size, int *key){ + return shmModSocket.recvfrom_nowait(buf, size, key); } /** * 鍙戦�佽姹備俊鎭苟绛夊緟鎺ユ敹搴旂瓟 - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int NetModSocket::sendandrecv( const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size){ - return shmModSocket.sendandrecv(send_buf, send_size, port, recv_buf, recv_size); +int NetModSocket::sendandrecv( const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size){ + return shmModSocket.sendandrecv(send_buf, send_size, key, recv_buf, recv_size); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int NetModSocket::sendandrecv_timeout( const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size, int sec, int nsec){ +int NetModSocket::sendandrecv_timeout( const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size, int sec, int nsec){ struct timespec timeout = {sec, nsec}; - return shmModSocket.sendandrecv_timeout(send_buf, send_size, port, recv_buf, recv_size, &timeout); + return shmModSocket.sendandrecv_timeout(send_buf, send_size, key, recv_buf, recv_size, &timeout); } -int NetModSocket::sendandrecv_nowait( const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size) { - return shmModSocket.sendandrecv_nowait(send_buf, send_size, port, recv_buf, recv_size); +int NetModSocket::sendandrecv_nowait( const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size) { + return shmModSocket.sendandrecv_nowait(send_buf, send_size, key, recv_buf, recv_size); } @@ -440,18 +440,18 @@ * 璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int NetModSocket::sub( void *topic, int size, int port){ - return shmModSocket.sub((char *)topic, size, port); +int NetModSocket::sub( void *topic, int size, int key){ + return shmModSocket.sub((char *)topic, size, key); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int NetModSocket::sub_timeout( void *topic, int size, int port, int sec, int nsec){ +int NetModSocket::sub_timeout( void *topic, int size, int key, int sec, int nsec){ struct timespec timeout = {sec, nsec}; - return shmModSocket.sub_timeout((char *)topic, size, port, &timeout); + return shmModSocket.sub_timeout((char *)topic, size, key, &timeout); } -int NetModSocket::sub_nowait( void *topic, int size, int port){ - return shmModSocket.sub_nowait((char *)topic, size, port); +int NetModSocket::sub_nowait( void *topic, int size, int key){ + return shmModSocket.sub_nowait((char *)topic, size, key); } @@ -460,18 +460,18 @@ * 鍙栨秷璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int NetModSocket::desub( void *topic, int size, int port){ - return shmModSocket.desub((char *)topic, size, port); +int NetModSocket::desub( void *topic, int size, int key){ + return shmModSocket.desub((char *)topic, size, key); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int NetModSocket::desub_timeout( void *topic, int size, int port, int sec, int nsec){ +int NetModSocket::desub_timeout( void *topic, int size, int key, int sec, int nsec){ struct timespec timeout = {sec, nsec}; - return shmModSocket.desub_timeout((char *)topic, size, port, &timeout); + return shmModSocket.desub_timeout((char *)topic, size, key, &timeout); } -int NetModSocket::desub_nowait( void *topic, int size, int port){ - return shmModSocket.desub_nowait((char *)topic, size, port); +int NetModSocket::desub_nowait( void *topic, int size, int key){ + return shmModSocket.desub_nowait((char *)topic, size, key); } @@ -480,18 +480,18 @@ * 鍙戝竷涓婚 * @topic 涓婚 * @content 涓婚鍐呭 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int NetModSocket::pub( char *topic, int topic_size, void *content, int content_size, int port){ - return shmModSocket.pub(topic, topic_size, content, content_size, port); +int NetModSocket::pub( char *topic, int topic_size, void *content, int content_size, int key){ + return shmModSocket.pub(topic, topic_size, content, content_size, key); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int NetModSocket::pub_timeout( char *topic, int topic_size, void *content, int content_size, int port, int sec, int nsec){ +int NetModSocket::pub_timeout( char *topic, int topic_size, void *content, int content_size, int key, int sec, int nsec){ struct timespec timeout = {sec, nsec}; - return shmModSocket.pub_timeout(topic, topic_size, content, content_size, port, &timeout); + return shmModSocket.pub_timeout(topic, topic_size, content, content_size, key, &timeout); } -int NetModSocket::pub_nowait( char *topic, int topic_size, void *content, int content_size, int port){ - return shmModSocket.pub_nowait(topic, topic_size, content, content_size, port); +int NetModSocket::pub_nowait( char *topic, int topic_size, void *content, int content_size, int key){ + return shmModSocket.pub_nowait(topic, topic_size, content, content_size, key); } diff --git a/src/socket/net_mod_socket.h b/src/socket/net_mod_socket.h index febb429..dfb7c11 100644 --- a/src/socket/net_mod_socket.h +++ b/src/socket/net_mod_socket.h @@ -100,13 +100,13 @@ * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ - int bind( int port); + int bind( int key); /** * 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ - int force_bind( int port); + int force_bind( int key); /** * 濡傛灉寤虹珛杩炴帴鐨勮妭鐐规病鏈夋帴鍙楀埌娑堟伅浼氫竴鐩寸瓑寰� @@ -150,34 +150,34 @@ /** * 鍙戦�佷俊鎭� - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ - int sendto( const void *buf, const int size, const int port); + int sendto( const void *buf, const int size, const int key); // 鍙戦�佷俊鎭秴鏃惰繑鍥炪�� @sec 绉� 锛� @nsec 绾崇 - int sendto_timeout( const void *buf, const int size, const int port, int sec, int nsec); + int sendto_timeout( const void *buf, const int size, const int key, int sec, int nsec); // 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� - int sendto_nowait( const void *buf, const int size, const int port); + int sendto_nowait( const void *buf, const int size, const int key); /** * 鎺ユ敹淇℃伅 - * @port 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * @key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ - int recvfrom( void **buf, int *size, int *port); + int recvfrom( void **buf, int *size, int *key); // 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 - int recvfrom_timeout( void **buf, int *size, int *port, int sec, int nsec); - int recvfrom_nowait( void **buf, int *size, int *port); + int recvfrom_timeout( void **buf, int *size, int *key, int sec, int nsec); + int recvfrom_nowait( void **buf, int *size, int *key); /** * 鏈湴鍙戦�佽姹備俊鎭苟绛夊緟鎺ユ敹搴旂瓟 - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ - int sendandrecv( const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size) ; + int sendandrecv( const void *send_buf, const int send_size, const int send_key, void **recv_buf, int *recv_size) ; // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 - int sendandrecv_timeout( const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size, int sec, int nsec) ; - int sendandrecv_nowait( const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size) ; + int sendandrecv_timeout( const void *send_buf, const int send_size, const int send_key, void **recv_buf, int *recv_size, int sec, int nsec) ; + int sendandrecv_nowait( const void *send_buf, const int send_size, const int send_key, void **recv_buf, int *recv_size) ; /** @@ -191,35 +191,35 @@ * 璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ - int sub( void *topic, int size, int port); + int sub( void *topic, int size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 - int sub_timeout( void *topic, int size, int port, int sec, int nsec); - int sub_nowait( void *topic, int size, int port); + int sub_timeout( void *topic, int size, int key, int sec, int nsec); + int sub_nowait( void *topic, int size, int key); /** * 鍙栨秷璁㈤槄鎸囧畾涓婚 * @topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ - int desub( void *topic, int size, int port); + int desub( void *topic, int size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 - int desub_timeout( void *topic, int size, int port, int sec, int nsec); - int desub_nowait( void *topic, int size, int port); + int desub_timeout( void *topic, int size, int key, int sec, int nsec); + int desub_nowait( void *topic, int size, int key); /** * 鍙戝竷涓婚 * @topic 涓婚 * @content 涓婚鍐呭 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ - int pub( char *topic, int topic_size, void *content, int content_size, int port); + int pub( char *topic, int topic_size, void *content, int content_size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 - int pub_timeout( char *topic, int topic_size, void *content, int content_size, int port, int sec, int nsec); - int pub_nowait( char *topic, int topic_size, void *content, int content_size, int port); + int pub_timeout( char *topic, int topic_size, void *content, int content_size, int key, int sec, int nsec); + int pub_nowait( char *topic, int topic_size, void *content, int content_size, int key); diff --git a/src/socket/net_mod_socket_wrapper.h b/src/socket/net_mod_socket_wrapper.h index ff5915d..562ce1d 100644 --- a/src/socket/net_mod_socket_wrapper.h +++ b/src/socket/net_mod_socket_wrapper.h @@ -28,34 +28,34 @@ * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int net_mod_socket_bind(void * _socket, int port); +int net_mod_socket_bind(void * _socket, int key); /** * 寮哄埗缁戝畾绔彛鍒皊ocket, 閫傜敤浜庣▼搴忛潪姝e父鍏抽棴鐨勬儏鍐典笅锛岄噸鍚▼搴忕粦瀹氬師鏉ヨ繕娌¢噴鏀剧殑key * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int net_mod_socket_force_bind(void * _socket, int port); +int net_mod_socket_force_bind(void * _socket, int key); /** * 鍙戦�佷俊鎭� - * @port 鍙戦�佺粰璋� + * @key 鍙戦�佺粰璋� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int net_mod_socket_sendto(void *_socket, const void *buf, const int size, const int port); +int net_mod_socket_sendto(void *_socket, const void *buf, const int size, const int key); // 鍙戦�佷俊鎭秴鏃惰繑鍥炪�� @sec 绉� 锛� @nsec 绾崇 -int net_mod_socket_sendto_timeout(void *_socket, const void *buf, const int size, const int port, int sec, int nsec); +int net_mod_socket_sendto_timeout(void *_socket, const void *buf, const int size, const int key, int sec, int nsec); // 鍙戦�佷俊鎭珛鍒昏繑鍥炪�� -int net_mod_socket_sendto_nowait(void *_socket, const void *buf, const int size, const int port); +int net_mod_socket_sendto_nowait(void *_socket, const void *buf, const int size, const int key); /** * 鎺ユ敹淇℃伅 - * @port 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� + * @key 浠庤皝鍝噷鏀跺埌鐨勪俊鎭� * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ -int net_mod_socket_recvfrom(void *_socket, void **buf, int *size, int *port); +int net_mod_socket_recvfrom(void *_socket, void **buf, int *size, int *key); // 鎺ュ彈淇℃伅瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int net_mod_socket_recvfrom_timeout(void *_socket, void **buf, int *size, int *port, int sec, int nsec); -int net_mod_socket_recvfrom_nowait(void *_socket, void **buf, int *size, int *port); +int net_mod_socket_recvfrom_timeout(void *_socket, void **buf, int *size, int *key, int sec, int nsec); +int net_mod_socket_recvfrom_nowait(void *_socket, void **buf, int *size, int *key); @@ -108,24 +108,24 @@ * 璁㈤槄鎸囧畾涓婚 * @topic 涓婚 * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ -int net_mod_socket_sub(void * _socket, void *topic, int size, int port); +int net_mod_socket_sub(void * _socket, void *topic, int size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec); -int net_mod_socket_sub_nowait(void * _socket, void *topic, int size, int port); +int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int key, int sec, int nsec); +int net_mod_socket_sub_nowait(void * _socket, void *topic, int size, int key); /** * 鍙栨秷璁㈤槄鎸囧畾涓婚 * @topic 涓婚,涓婚涓虹┖鏃跺彇娑堝叏閮ㄨ闃� * @size 涓婚闀垮害 - * @port 鎬荤嚎绔彛 + * @key 鎬荤嚎绔彛 */ int net_mod_socket_desub(void * _socket, void *topic, int size, int key); // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int net_mod_socket_desub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec); -int net_mod_socket_desub_nowait(void * _socket, void *topic, int size, int port); +int net_mod_socket_desub_timeout(void * _socket, void *topic, int size, int key, int sec, int nsec); +int net_mod_socket_desub_nowait(void * _socket, void *topic, int size, int key); /** -- Gitblit v1.8.0