| | |
| | | #define NET_MODE_REQUEST_HEAD_LENGTH 16 |
| | | #define NET_MODE_RESPONSE_HEAD_LENGTH 4 |
| | | |
| | | |
| | | |
| | | class NetModServerSocket; |
| | | |
| | | struct net_node_t |
| | |
| | | }; |
| | | |
| | | class NetModSocket { |
| | | struct pool{ /* Represents a pool of connected descriptors */ //line:conc:echoservers:beginpool |
| | | int maxfd; /* Largest descriptor in read_set */ |
| | | fd_set read_set; /* Set of all active descriptors */ |
| | | fd_set ready_read_set; /* Subset of descriptors ready for reading */ |
| | | |
| | | fd_set write_set; |
| | | fd_set ready_write_set; |
| | | |
| | | fd_set except_set; |
| | | fd_set ready_except_set; |
| | | |
| | | int nready; /* Number of ready descriptors from select */ |
| | | int maxi; /* Highwater index into client array */ |
| | | int connfd[FD_SETSIZE]; /* Set of active descriptors */ |
| | | // net_node_t *nodes[FD_SETSIZE]; |
| | | // rio_t clientrio[FD_SETSIZE]; /* Set of active read buffers */ |
| | | std::map<int, net_node_t*> connfdNodeMap; |
| | | std::map<std::string, int> connectionMap; |
| | | } ; |
| | | |
| | | friend class NetModServerSocket; |
| | | private: |
| | | static std::map<std::string, int> connectionMap; |
| | | ShmModSocket shmModSocket; |
| | | |
| | | ShmModSocket shmModSocket; |
| | | pool req_resp_pool; |
| | | |
| | | 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); |
| | | |
| | | int connect(const char *host, int port); |
| | | void remove_connect(const char *host, int port); |
| | | void init_req_rep_req_resp_pool(); |
| | | int connect( net_node_t*); |
| | | void close_connect(int connfd); |
| | | int read_response(int clientfd, net_mod_recv_msg_t *recv_msg); |
| | | int write_request(int clientfd, int key, void *send_buf, int send_size); |
| | | |
| | | |
| | | public: |
| | | |
| | |
| | | int 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); |
| | | |
| | | |
| | | int sendandrecv_safe(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 消息组 |