zhangmeng
2020-08-04 4acab9cb4dae6ddc881e6bd5454715063c1a7d4b
libcsoftbus_func.h
@@ -17,6 +17,11 @@
 * 整个进程退出时需要执行这个方法,该方法首先会检查是否还有其他进程在使用该共享内存,如果还有其他进程在使用就只是detach,如果没有其他进程在使用则销毁整块内存。
 */
typedef void(*tfn_shm_destroy)();
/**
 * 获取key
 */
typedef int(*tfn_shm_alloc_key) ();
//移除不包含在keys中的队列
typedef void (*tfn_shm_rm_dead_queue)(void *keys, int length);
@@ -146,6 +151,84 @@
 */
typedef int(*tfn_socket_port) (void*);
//////////////////////////////////////////////
// dgram socket
/**
 * 创建socket
 * @return socket地址
*/
typedef void*(*tfn_dgram_socket_open) ();
/**
 * 关闭socket
 * @return 0 成功, 其他值 失败的错误码
*/
typedef int(*tfn_dgram_socket_close) (void*);
/**
 * 绑定端口到socket, 如果不绑定则系统自动分配一个
 * @return 0 成功, 其他值 失败的错误码
*/
typedef int(*tfn_dgram_socket_bind) (void*, int);
typedef tfn_dgram_socket_bind tfn_dgram_socket_force_bind;
/**
 * 发送信息
 * @port 发送给谁
 * @return 0 成功, 其他值 失败的错误码
 */
typedef int(*tfn_dgram_socket_sendto) (void*, const void*, const int, const int);
// 发送信息超时返回。 @sec 秒 , @nsec 纳秒
typedef int(*tfn_dgram_socket_sendto_timeout) (void*, const void*, const int, const int, int, int);
// 发送信息立刻返回。
typedef tfn_dgram_socket_sendto tfn_dgram_socket_sendto_nowait;
/**
 * 接收信息
 * @port 从谁哪里收到的信息
 * @return 0 成功, 其他值 失败的错误码
*/
typedef int(*tfn_dgram_socket_recvfrom) (void*, void**, int*, int*);
typedef int(*tfn_dgram_socket_recvfrom_timeout) (void*, void**, int*, int*, int, int);
typedef tfn_dgram_socket_recvfrom tfn_dgram_socket_recvfrom_nowait;
/**
 * 发送请求信息并等待接收应答
 * @port 发送给谁
 * @return 0 成功, 其他值 失败的错误码
*/
typedef int(*tfn_dgram_socket_sendandrecv) (void*, const void*, const int, const int, void**, int*);
typedef int(*tfn_dgram_socket_sendandrecv_timeout) (void*, const void*, const int, const int, void**, int*, int, int);
typedef tfn_dgram_socket_sendandrecv tfn_dgram_socket_sendandrecv_nowait;
/**
 * 启动bus
 *
 * @return 0 成功, 其他值 失败的错误码
*/
typedef int(*tfn_dgram_socket_start_bus) (void*);
/**
 * 订阅指定主题
 * @topic 主题
 * @size 主题长度
 * @port 总线端口
 */
typedef int(*tfn_dgram_socket_sub) (void*, void*, int, int);
typedef int(*tfn_dgram_socket_sub_timeout) (void*, void*, int, int, int, int);
typedef tfn_dgram_socket_sub tfn_dgram_socket_sub_nowait;
/**
 * 发布主题
 * @topic 主题
 * @content 主题内容
 * @port 总线端口
 */
typedef int(*tfn_dgram_socket_pub) (void*, void*, int, void*, int, int);
typedef int(*tfn_dgram_socket_pub_timeout) (void*, void*, int, void*, int, int, int, int);
typedef tfn_dgram_socket_pub tfn_dgram_socket_pub_nowait;
/**
 * 获取soket端口号
 */
typedef int(*tfn_dgram_socket_port) (void*);
/**
 * 释放存储接收信息的buf
 */
typedef void(*tfn_dgram_socket_free) (void*);
#ifdef __cplusplus
}
#endif