#ifndef __NET_SERVER_MODE_SOCKET_H__ #define __NET_SERVER_MODE_SOCKET_H__ #include "usg_common.h" #include "shm_mod_socket.h" #include "socket_io.h" class NetModServerSocket { struct net_mod_msg_t { int key; socket_mod_t mod; size_t content_size; void * content; size_t topic_size; void * topic; }; 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_set; /* Subset of descriptors ready for reading */ int nready; /* Number of ready descriptors from select */ int maxi; /* Highwater index into client array */ int clientfd[FD_SETSIZE]; /* Set of active descriptors */ // rio_t clientrio[FD_SETSIZE]; /* Set of active read buffers */ } ; private: int listenfd; int port; ShmModSocket shmModSocket; pool pool; void *buf; void *topic_buf; char *response_buf; size_t max_buf; size_t max_topic_buf; size_t max_response_buf; void init_pool(int listenfd); void add_client(int connfd); void check_clients(); int process_client(int connfd); public: NetModServerSocket(int port); /* * 启动 server * @return 0 success, 其他 failture */ int start(); ~NetModServerSocket(); }; #endif