wangzhengquan
2020-10-13 938f6f1dddd1b2b9549ad741ee9578ae2567fd4f
update
4个文件已添加
1个文件已修改
69 ■■■■■ 已修改文件
src/socket/net_mod_server_socket.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_server_socket_wrapper.c 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_server_socket_wrapper.h 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_socket_wrapper.c 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_socket_wrapper.h 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_server_socket.h
@@ -44,6 +44,10 @@
public:
    NetModServerSocket(int port);
    /*
     * 启动 server
    */
    void start();
    ~NetModServerSocket();
src/socket/net_mod_server_socket_wrapper.c
src/socket/net_mod_server_socket_wrapper.h
New file
@@ -0,0 +1,17 @@
#ifndef __NET_MOD_SERVER_SOCKET_H__
#define __NET_MOD_SERVER_SOCKET_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
src/socket/net_mod_socket_wrapper.c
src/socket/net_mod_socket_wrapper.h
New file
@@ -0,0 +1,48 @@
#ifndef __NET_MOD_SOCKET_H__
#define __NET_MOD_SOCKET_H__
#include "net_mod_socket.h"
#ifdef __cplusplus
extern "C" {
#endif
struct net_mod_socket
{
    NetModSocket *sockt;
};
void * net_mod_socket_open();
void net_mod_socket_close();
/**
 * 向node_arr 中的所有网络节点发送请求消息,节点的返回信息汇总并存储在recv_arr中
 * @node_arr 网络节点组, @node_arr_len该数组长度
 * @send_buf 发送的消息,@send_size 该消息体的长度
 * @recv_arr 返回的应答消息组,@recv_arr_size 该数组长度
 * @return 成功发送的节点的个数
 */
int net_mod_socket_sendandrecv(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);
/**
 * 销毁sendandrecv方法返回的消息组
 * @arr 消息组
 * @size 消息组的长度
 */
static void  net_mod_socket_free_recv_msg_arr(net_mod_recv_msg_t * arr, size_t size);
 /**
 * 向node_arr 中的所有网络节点发布消息
 * @node_arr 网络节点组, @node_arr_len该数组长度
 * @topic 主题,@topic_size 该主题的长度
 * @content 内容,@content_size 内容长度
 * @return 成功发布的节点的个数
 */
int net_mod_socket_pub(net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size);
#ifdef __cplusplus
}
#endif
#endif