| | |
| | | #include "net_mod_server_socket.h" |
| | | |
| | | #include "socket_io.h" |
| | | #include "net_mod_socket_io.h" |
| | | |
| | | NetModServerSocket::NetModServerSocket(int port, ShmModSocket * modsocket) |
| | | NetModServerSocket::NetModServerSocket(int port, ShmModSocket * modsocket): shm_mod_socket(modsocket) |
| | | { |
| | | shm_mod_socket = modsocket; |
| | | |
| | | char portstr[32]; |
| | | sprintf(portstr, "%d", port); |
| | | listenfd = Open_listenfd(portstr); |
| | |
| | | } |
| | | /* $end add_client */ |
| | | |
| | | |
| | | |
| | | /* $begin check_clients */ |
| | | void NetModServerSocket::check_clients() |
| | | { |
| | |
| | | if ((connfd > 0) && (FD_ISSET(connfd, &pool.ready_set))) |
| | | { |
| | | pool.nready--; |
| | | if ((n = Rio_readlineb(&rio, buf, MAXLINE)) != 0) |
| | | if ((n = rio_readpkgb(&rio, buf, MAXLINE)) > 0) |
| | | { |
| | | |
| | | Rio_writen(connfd, buf, n); |
| | | Rio_writen(connfd, PKG_SEP, strlen(PKG_SEP)); |
| | | // shm_mod_socket->sendto(buf, n, msg->key); |
| | | // net_mod_msg_t *msg = (net_mod_msg_t*)buf; |
| | | // if(msg.mod == PUB_SUB) { |