wangzhengquan
2020-10-10 9ebe80228c7b7cb35ccaeaaa46ccf726bf71d6bd
src/socket/net_mod_server_socket.c
@@ -1,11 +1,10 @@
#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);
@@ -81,6 +80,8 @@
}
/* $end add_client */
/* $begin check_clients */
void  NetModServerSocket::check_clients()
{
@@ -97,10 +98,11 @@
    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) {