From 9e64ecf008d2258cab142b10f07eca6b538d6c19 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期三, 05 八月 2020 19:39:53 +0800 Subject: [PATCH] update --- src/socket/include/shm_socket.h | 46 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/socket/include/shm_socket.h b/src/socket/include/shm_socket.h index 8b14f06..6bb0448 100644 --- a/src/socket/include/shm_socket.h +++ b/src/socket/include/shm_socket.h @@ -4,15 +4,8 @@ #include "usg_common.h" #include "usg_typedef.h" #include "shm_queue.h" -#include "shm_allocator.h" -#include "mem_pool.h" -#include "hashtable.h" -#include "sem_util.h" - -#ifdef __cplusplus -extern "C" { -#endif + enum shm_msg_type_t { @@ -21,6 +14,24 @@ SHM_SOCKET_CLOSE = 3, SHM_COMMON_MSG = 4 +}; + +enum shm_socket_flag_t +{ + SHM_MSG_TIMEOUT = 1, + SHM_MSG_NOWAIT = 2 +}; + +enum shm_socket_type_t +{ + SHM_SOCKET_STREAM = 1, + SHM_SOCKET_DGRAM = 2 + +}; + +enum shm_socket_error_type_t { + SHM_SOCKET_ECONNFAILED = 1, + SHM_SOCKET_ETIMEOUT = 2 }; enum shm_connection_status_t { @@ -38,9 +49,13 @@ } shm_msg_t; + + typedef struct shm_socket_t { + shm_socket_type_t socket_type; // 鏈湴port int port; + bool force_bind; shm_connection_status_t status; SHMQueue<shm_msg_t> *queue; SHMQueue<shm_msg_t> *remoteQueue; @@ -54,13 +69,16 @@ -shm_socket_t *shm_open_socket(); +shm_socket_t *shm_open_socket(shm_socket_type_t socket_type); int shm_close_socket(shm_socket_t * socket) ; int shm_socket_bind(shm_socket_t * socket, int port) ; + +int shm_socket_force_bind(shm_socket_t * socket, int port) ; + int shm_listen(shm_socket_t * socket) ; @@ -70,12 +88,16 @@ int shm_send(shm_socket_t * socket, const void *buf, const int size) ; + int shm_recv(shm_socket_t * socket, void **buf, int *size) ; +int shm_sendto(shm_socket_t *socket, const void *buf, const int size, const int port, const struct timespec * timeout = NULL, const int flags=0); + +int shm_recvfrom(shm_socket_t *socket, void **buf, int *size, int *port, struct timespec * timeout = NULL, int flags=0); + +int shm_sendandrecv(shm_socket_t *socket, const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size, + struct timespec * timeout = NULL, int flags=0); -#ifdef __cplusplus -} -#endif #endif \ No newline at end of file -- Gitblit v1.8.0