#ifndef __NET_MODE_SOCKET_H__ #define __NET_MODE_SOCKET_H__ #include "usg_common.h" #include "shm_mod_socket.h" #include "socket_io.h" #define GET(p) (*(uint32_t *)(p)) #define PUT(p, val) (*(uint32_t *)(p) = (val)) #define NET_MODE_REQUEST_HEAD_LENGTH 12 #define NET_MODE_RESPONSE_HEAD_LENGTH 4 struct net_node_t { const char *host; int port; int key; }; struct net_mod_request_head_t { uint32_t mod; uint32_t key; uint32_t content_length; }; struct net_mod_response_head_t { // socket_mod_t mod; // int key; uint32_t content_length; }; struct net_mod_recv_msg_t { char host[128]; int port; int key; void *content; int content_length; }; class NetModSocket { private: static std::map connectionMap; ShmModSocket shmModSocket; public: NetModSocket(); int sendandrecv(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, net_mod_recv_msg_t ** resp_arr, int *resp_arr_size); ~NetModSocket(); static void free_recv_msg_arr(net_mod_recv_msg_t * arr, size_t size); static void * encode_request_head(net_mod_request_head_t & request); static net_mod_request_head_t decode_request_head(void *headbs); static void * encode_response_head(net_mod_response_head_t & response); static net_mod_response_head_t decode_response_head(void *_headbs); }; #endif