wangzhengquan
2020-11-30 970c212a22d1f1f33780eb58f606008fd6e01e3c
update
2个文件已删除
7个文件已修改
367 ■■■■■ 已修改文件
lib/libusgcommon.so 补丁 | 查看 | 原始文档 | blame | 历史
libusgcommon.a 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_server_socket.c 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_socket.c 247 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_socket.h 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_socket_wrapper.c 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/net_mod_socket_wrapper.h 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test_net_socket/Makefile 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
test_net_socket/test_net_mod_socket.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/libusgcommon.so
Binary files differ
libusgcommon.a
Binary files differ
src/socket/net_mod_server_socket.c
@@ -125,10 +125,12 @@
int NetModServerSocket::process_client(int connfd) {
  net_mod_request_head_t request_head;
  net_mod_response_head_t response_head;
  int ret;
  char request_head_bs[NET_MODE_REQUEST_HEAD_LENGTH];
  void  *recv_buf;
// char tmp[8196];
  int recv_size, response_buf_size;
  struct timespec timeout;
  if (rio_readn(connfd, request_head_bs, NET_MODE_REQUEST_HEAD_LENGTH) !=  NET_MODE_REQUEST_HEAD_LENGTH)
  {
@@ -136,7 +138,8 @@
  }
  request_head = NetModSocket::decode_request_head(request_head_bs);
// printf("server received request from host = %s:%d\n", request_head.host, request_head.port);
printf("server received request from host = %s:%d, key = %d, timeout=%d,\n",
  request_head.host, request_head.port , request_head.key, request_head.timeout);
  if(request_head.content_length > max_buf) {
   
@@ -152,14 +155,32 @@
    return -1;
  }
  if(request_head.mod == REQ_REP) {
 
    memcpy(response_head.host, request_head.host, NI_MAXHOST);
    response_head.port = request_head.port;
    response_head.key = request_head.key;
    if(shmModSocket.sendandrecv_unsafe(buf, request_head.content_length, request_head.key, &recv_buf, &recv_size) != 0) {
    if(request_head.timeout > 0) {
      timeout.tv_sec = request_head.timeout / 1000;
      timeout.tv_nsec = (request_head.timeout - timeout.tv_sec * 1000) * 10e6;
      // printf(" timeout.tv_sec = %d,  timeout.tv_nsec=%ld\n",  timeout.tv_sec,  timeout.tv_nsec );
      ret = shmModSocket.sendandrecv_unsafe_timeout(buf, request_head.content_length, request_head.key, &recv_buf, &recv_size, &timeout);
    }
    else if(request_head.timeout == 0) {
      ret = shmModSocket.sendandrecv_unsafe_nowait(buf, request_head.content_length, request_head.key, &recv_buf, &recv_size);
    }
    else if(request_head.timeout == -1) {
      ret = shmModSocket.sendandrecv_unsafe(buf, request_head.content_length, request_head.key, &recv_buf, &recv_size);
    }
    if( ret != 0) {
      // 没有对应的key
      response_head.code = 1;
      response_head.code = ret;
      response_head.content_length = 0;
      if( rio_writen(connfd, NetModSocket::encode_response_head(response_head), NET_MODE_RESPONSE_HEAD_LENGTH) != NET_MODE_RESPONSE_HEAD_LENGTH )
        return -1;
@@ -192,7 +213,6 @@
    
   
  } else if(request_head.mod == BUS) {
    // TODO: pub response
    if(request_head.topic_length > max_topic_buf) {
      if( (topic_buf = realloc(topic_buf, request_head.topic_length)) == NULL ) {
         LoggerFactory::getLogger()->error(errno, "NetModServerSocket::process_client realloc topic_buf");
@@ -206,7 +226,28 @@
      return -1;
    }
LoggerFactory::getLogger()->debug("====server pub %s===\n", buf);
    shmModSocket.pub((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key);
    memcpy(response_head.host, request_head.host, NI_MAXHOST);
    response_head.port = request_head.port;
    response_head.key = request_head.key;
    if(request_head.timeout > 0) {
      timeout.tv_sec = request_head.timeout / 1000;
      timeout.tv_nsec = (request_head.timeout - timeout.tv_sec * 1000) * 10e6;
      ret = shmModSocket.pub_timeout((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key, &timeout);
    }
    else if(request_head.timeout == 0) {
      ret = shmModSocket.pub_nowait((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key);
    }
    else if(request_head.timeout == -1) {
      ret = shmModSocket.pub((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key);
    }
    response_head.code = ret;
    response_head.content_length = 0;
    if( rio_writen(connfd, NetModSocket::encode_response_head(response_head), NET_MODE_RESPONSE_HEAD_LENGTH) != NET_MODE_RESPONSE_HEAD_LENGTH )
      return -1;
  }
  return 0;
src/socket/net_mod_socket.c
@@ -39,8 +39,8 @@
  _sendandrecv_(node_arr,  arrlen, send_buf,send_size, recv_arr, recv_arr_size, -1);
}
int NetModSocket::sendandrecv_timeout(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, 
  net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int  timeout) {
  _sendandrecv_(node_arr,  arrlen, send_buf,send_size, recv_arr, recv_arr_size, timeout);
  net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int  msec) {
  _sendandrecv_(node_arr,  arrlen, send_buf,send_size, recv_arr, recv_arr_size, msec);
}
int NetModSocket::sendandrecv_nowait(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, 
  net_mod_recv_msg_t ** recv_arr, int *recv_arr_size) {
@@ -63,6 +63,7 @@
// printf("open after: %s\n", mapKey); 
  if(connfd < 0) {
    LoggerFactory::getLogger()->error(errno, "NetModSocket::connect %s:%d ", node->host, node->port);
    exit(1);
    return -1;
  }
  
@@ -104,12 +105,12 @@
    }
  }
  LoggerFactory::getLogger()->debug( "closed %d\n", connfd);
  // LoggerFactory::getLogger()->debug( "NetModSocket::close_connect %d\n", connfd);
}
int NetModSocket::_sendandrecv_(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, 
  net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int  timeout = 5 * 1000) {
  net_mod_recv_msg_t ** recv_arr, int *recv_arr_size, int  msec ) {
  int i, n, recv_size, connfd;
  net_node_t *node;
@@ -119,7 +120,7 @@
  
  net_mod_request_head_t request_head = {};
 
  int n_req = 0, n_recv_suc = 0, n_resp;
  int n_req = 0, n_recv_suc = 0, n_resp =0;
   
  net_mod_recv_msg_t *ret_arr = (net_mod_recv_msg_t *)calloc(arrlen, sizeof(net_mod_recv_msg_t));
@@ -151,13 +152,12 @@
    request_head.port = node->port;
    request_head.key = node->key;
    request_head.content_length = send_size;
    request_head.timeout = msec;
 // printf("write_request %s:%d\n", request_head.host, request_head.port);
    if(write_request(connfd, request_head, send_buf, send_size) != 0) {
    if(write_request(connfd, request_head, send_buf, send_size, NULL, 0) != 0) {
      LoggerFactory::getLogger()->error("write_request failture %s:%d\n", node->host, node->port);
      close_connect(mpool, connfd);
      // mpool.conns[i].fd = -1;
    } else {
      n_req++;
    }
@@ -167,12 +167,10 @@
// printf(" mpool.maxi = %d\n",  mpool.maxi);
// printf(" n_req = %d\n", n_req);
// int tmp = 0;
  while(n_resp < n_req)
  {
// printf(" while %d\n", tmp++);
    /* Wait for listening/connected descriptor(s) to become ready */
    if( (mpool.nready = poll(mpool.conns, mpool.maxi + 1, timeout) ) <= 0) {
    if( (mpool.nready = poll(mpool.conns, mpool.maxi + 1, msec) ) <= 0) {
       // wirite_set 和 read_set 在指定时间内都没准备好
      break;
    }
@@ -185,18 +183,17 @@
          mpool.nready--;
// printf("POLLIN %d\n", connfd);
          if( (n = read_response(connfd, ret_arr+n_recv_suc)) == 0) {
            // 成功收到返回消息,清空读入位
            mpool.conns[i].fd = -1;
            n_recv_suc++;
            
          } else if(n == -1)  {
          }
          // else if(n == -1)  {
          //   // 网络错误
          // } else {
          //   // 对方key是关闭的
          // }
            mpool.conns[i].fd = -1;
            close_connect(mpool, connfd);
          } else {
            mpool.conns[i].fd = -1;
          }
          n_resp++;
// printf("read response %d\n", n);
          
@@ -217,6 +214,7 @@
    }
  }
   //超时后,关闭超时连接
  for (i = 0; i <= mpool.maxi; i++) {
    if ( (connfd = mpool.conns[i].fd) > 0 ) {
      // 关闭并清除写入或读取失败的连接
@@ -233,6 +231,128 @@
  }
  return n_recv_suc;
     
}
int NetModSocket::pub(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size) {
  return _pub_(node_arr, arrlen, topic, topic_size, content,   content_size, -1);
}
int NetModSocket::pub_nowait(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size) {
  return _pub_(node_arr, arrlen, topic, topic_size, content,   content_size, 0);
}
int NetModSocket::pub_timeout(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size, int  msec ) {
  return _pub_(node_arr, arrlen, topic, topic_size, content, content_size, msec);
}
// int  pub(char *topic, int topic_size, void *content, int content_size, int port);
int NetModSocket::_pub_(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content,
 int content_size, int  timeout) {
  int i, connfd;
  net_node_t *node;
  net_mod_request_head_t request_head;
  net_mod_recv_msg_t recv_msg;
  char portstr[32];
  int n_req = 0, n_pub_suc = 0, n_resp = 0;
  int ret;
  pool mpool;
  init_conn_pool(mpool);
  for (i = 0; i < arrlen; i++) {
    node = &node_arr[i];
    if(node->host == NULL) {
      // 本地发送
      if(shmModSocket.pub(topic, topic_size, content, content_size, node->key) == 0 ) {
         n_pub_suc++;
      }
    } else {
      sprintf(portstr, "%d", node->port);
      if( (connfd = connect(mpool, node)) < 0 ) {
        continue;
      }
      request_head.mod = BUS;
      request_head.key = node->key;
      request_head.content_length = content_size;
      request_head.topic_length = strlen(topic) + 1;
      request_head.timeout = timeout;
      if(write_request(connfd, request_head, content, content_size, topic, request_head.topic_length) != 0) {
        LoggerFactory::getLogger()->error(" NetModSocket::_pub_ write_request failture %s:%d\n", node->host, node->port);
        close_connect(mpool, connfd);
      } else {
        n_req++;
      }
    }
  }
  while(n_resp < n_req)
  {
    /* Wait for listening/connected descriptor(s) to become ready */
    if( (mpool.nready = poll(mpool.conns, mpool.maxi + 1, timeout) ) <= 0) {
       // wirite_set 和 read_set 在指定时间内都没准备好
      break;
    }
// printf("mpool.nready =%d\n", mpool.nready);
    for (i = 0; (i <= mpool.maxi) && (mpool.nready > 0); i++) {
      if ( (connfd = mpool.conns[i].fd) > 0 ) {
        if (mpool.conns[i].revents & POLLIN )
        {
          mpool.nready--;
// printf("POLLIN %d\n", connfd);
          if( (ret = read_response(connfd, &recv_msg)) == 0) {
            // 成功收到返回消息,清空读入位
            mpool.conns[i].fd = -1;
            n_pub_suc++;
          }
          // else if(ret == -1)  {
          //   // 网络连接错误
          // } else {
          //   // 对方的key是关闭的
          // }
          mpool.conns[i].fd = -1;
          close_connect(mpool, connfd);
          n_resp++;
// printf("read response %d\n", n);
        }
        if (mpool.conns[i].revents & POLLOUT ) {
  // printf("poll POLLOUT %d\n", connfd);
        }
        if (mpool.conns[i].revents & (POLLRDHUP | POLLHUP | POLLERR) )
        {
// printf("poll POLLERR %d\n", connfd);
          mpool.nready--;
          mpool.conns[i].fd = -1;
          close_connect(mpool, connfd);
        }
      }
    }
  }
  //超时后,关闭超时连接
  for (i = 0; i <= mpool.maxi; i++) {
    if ( (connfd = mpool.conns[i].fd) > 0 ) {
      // 关闭并清除写入或读取失败的连接
      close_connect(mpool, connfd);
      mpool.conns[i].fd = -1;
    }
  }
  mpool.maxi = -1;
  return n_pub_suc;
}
@@ -356,76 +476,6 @@
     
}
// int  pub(char *topic, int topic_size, void *content, int content_size, int port);
int NetModSocket::pub(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size) {
  int i, clientfd;
  net_node_t *node;
  char *buf;
  int max_buf_size, buf_size;
  net_mod_request_head_t request_head;
  char portstr[32];
  int nsuc = 0;
  if((buf = (char *)malloc(MAXBUF)) == NULL) {
    LoggerFactory::getLogger()->error(errno, "NetModSocket::sendandrecv malloc");
    exit(1);
  } else {
     max_buf_size = MAXBUF;
  }
  for (i = 0; i< arrlen; i++) {
    node = &node_arr[i];
    if(node->host == NULL) {
      // 本地发送
      if(shmModSocket.pub(topic, topic_size, content, content_size, node->key) == 0 ) {
         nsuc++;
      }
    } else {
      sprintf(portstr, "%d", node->port);
      clientfd = open_clientfd(node->host, portstr);
      if(clientfd < 0) {
        continue;
      }
      request_head.mod = BUS;
      request_head.key = node->key;
      request_head.content_length = content_size;
      request_head.topic_length = strlen(topic) + 1;
      buf_size = NET_MODE_REQUEST_HEAD_LENGTH + content_size + request_head.topic_length;
      if(max_buf_size < buf_size) {
        if( ( buf = (char *)realloc(buf, buf_size)) == NULL) {
           LoggerFactory::getLogger()->error(errno, "NetModSocket::pub realloc buf ");
        } else {
          max_buf_size = buf_size;
        }
      }
      memcpy(buf, NetModSocket::encode_request_head(request_head), NET_MODE_REQUEST_HEAD_LENGTH);
      memcpy(buf + NET_MODE_REQUEST_HEAD_LENGTH, content, content_size);
      memcpy(buf + NET_MODE_REQUEST_HEAD_LENGTH + content_size, topic, request_head.topic_length);
      if(rio_writen(clientfd, buf, buf_size) != buf_size ) {
        LoggerFactory::getLogger()->error(errno, "NetModSocket::pub rio_writen conent ");
      } else {
        nsuc++;
      }
      close(clientfd);
    }
  }
  free(buf);
  return nsuc;
}
/**
@@ -573,9 +623,8 @@
//======================================================================================
int NetModSocket::write_request(int clientfd, net_mod_request_head_t &request_head, void *send_buf, int send_size) {
int NetModSocket::write_request(int clientfd, net_mod_request_head_t &request_head,
  void *content_buf, int content_size, void *topic_buf, int topic_size) {
 
  int buf_size;
  char *buf;
@@ -587,7 +636,7 @@
    max_buf_size = MAXBUF;
  }
  buf_size = send_size + NET_MODE_REQUEST_HEAD_LENGTH;
  buf_size = NET_MODE_REQUEST_HEAD_LENGTH + content_size + topic_size  ;
  if(max_buf_size < buf_size) {
    
    if((buf = (char *)realloc(buf, buf_size)) == NULL) {
@@ -599,7 +648,9 @@
  }
  memcpy(buf, NetModSocket::encode_request_head(request_head), NET_MODE_REQUEST_HEAD_LENGTH);
  memcpy(buf + NET_MODE_REQUEST_HEAD_LENGTH, send_buf, send_size);
  memcpy(buf + NET_MODE_REQUEST_HEAD_LENGTH, content_buf, content_size);
  if(topic_size != 0 )
    memcpy(buf + NET_MODE_REQUEST_HEAD_LENGTH + content_size, topic_buf, topic_size);
  if(rio_writen(clientfd, buf, buf_size) != buf_size ) {
    LoggerFactory::getLogger()->error(errno, "NetModSocket::write_request  rio_writen");
@@ -629,7 +680,7 @@
  response_head =  NetModSocket::decode_response_head(response_head_bs);
// printf(">>>> read_response %s\n", response_head.host);
  if(response_head.code != 0) {
    // 对方没有对应的key
    // 代理服务没能成功发送给对应的key
    return 1;
  }
@@ -697,6 +748,9 @@
  tmp_ptr += 4;
  PUT(tmp_ptr, htonl(head.topic_length));
  
  tmp_ptr += 4;
  PUT_INT32(tmp_ptr, htonl(head.timeout));
  
  return headbs;
}
@@ -723,6 +777,9 @@
  tmp_ptr += 4;
  head.topic_length = ntohl(GET(tmp_ptr));
 
  tmp_ptr += 4;
  head.timeout = ntohl(GET_INT32(tmp_ptr));
  return head;
}
src/socket/net_mod_socket.h
@@ -9,11 +9,8 @@
#define GET(p)       (*(uint32_t *)(p))
#define PUT(p, val)  (*(uint32_t *)(p) = (val))
#define ERROR_NET_MOD_SOCKET_ADDR_IN_USE 1
#define GET_INT32(p)       (*(int32_t *)(p))
#define PUT_INT32(p, val)  (*(int32_t *)(p) = (val))
class NetModServerSocket;
@@ -24,25 +21,30 @@
    int key;
};
#define NET_MODE_REQUEST_HEAD_LENGTH (NI_MAXHOST + 5 * sizeof(uint32_t))
#define NET_MODE_REQUEST_HEAD_LENGTH (NI_MAXHOST + 6 * sizeof(uint32_t))
// 请求头
struct net_mod_request_head_t {
    uint32_t mod;
  char host[NI_MAXHOST];
  uint32_t port;
    uint32_t key;
    uint32_t content_length;
    uint32_t topic_length;
    uint32_t content_length; // 请求内容
    uint32_t topic_length; // 请求主题
  int32_t timeout; // -1 block, 0 nowait , > 0 timeout
};
#define NET_MODE_RESPONSE_HEAD_LENGTH (NI_MAXHOST + 4 * sizeof(uint32_t))
// 应答头
struct net_mod_response_head_t {
    // socket_mod_t mod;
  char host[NI_MAXHOST];
  uint32_t port;
    uint32_t key;
  uint32_t code;
  uint32_t code; //返回值, 0 为成功
    uint32_t content_length;
};
@@ -84,11 +86,12 @@
  int connect(pool& mpool, net_node_t* node);
  void close_connect(pool& mpool , int connfd);
  int read_response(int clientfd, net_mod_recv_msg_t *recv_msg);
  int write_request(int clientfd, net_mod_request_head_t &request_head, void *send_buf, int send_size);
  int write_request(int clientfd, net_mod_request_head_t &request_head, void *send_buf, int send_size, void *topic_buf, int topic_size);
  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 timeout);
  int _pub_(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size, int timeout) ;
  
public:
@@ -184,6 +187,21 @@
  */
  int  start_bus();
   /**
   * 向node_arr 中的所有网络节点发布消息
   * @node_arr 网络节点组, @node_arr_len该数组长度
   * @topic 主题,@topic_size 该主题的长度
   * @content 内容,@content_size 内容长度
   * @return 成功发布的节点的个数
   */
  int pub(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size) ;
  int pub_nowait(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size);
  /**
   * @msec 毫秒 (千分之一秒)
   */
  int pub_timeout(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size, int  msec);
  /**
   * 订阅指定主题
   * @topic 主题
@@ -220,14 +238,8 @@
   /**
   * 向node_arr 中的所有网络节点发布消息
   * @node_arr 网络节点组, @node_arr_len该数组长度
   * @topic 主题,@topic_size 该主题的长度
   * @content 内容,@content_size 内容长度
   * @return 成功发布的节点的个数
   */
  int pub(net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size);
  /**
   * 获取soket key
src/socket/net_mod_socket_wrapper.c
@@ -125,11 +125,13 @@
    net_mod_socket_t *sockt = (net_mod_socket_t *)_socket;
    return sockt->sockt->pub(node_arr, node_arr_len, topic, topic_size, content, content_size);
}
int net_mod_socket_pub_timeout(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int timeout){
    return 0;
int net_mod_socket_pub_timeout(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int msec){
    net_mod_socket_t *sockt = (net_mod_socket_t *)_socket;
    return sockt->sockt->pub_timeout(node_arr, node_arr_len, topic, topic_size, content, content_size, msec);
}
int net_mod_socket_pub_nowait(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size){
    return 0;
int net_mod_socket_pub_nowait(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size){
    net_mod_socket_t *sockt = (net_mod_socket_t *)_socket;
    return sockt->sockt->pub_nowait(node_arr, node_arr_len, topic, topic_size, content, content_size);
}
src/socket/net_mod_socket_wrapper.h
@@ -103,7 +103,10 @@
 * @return 成功发布的节点的个数
 */
int net_mod_socket_pub(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size);
int net_mod_socket_pub_timeout(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int timeout);
/*
 * @msec 毫秒(千分之一秒)
 */
int net_mod_socket_pub_timeout(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int msec);
int net_mod_socket_pub_nowait(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size);
/**
test_net_socket/Makefile
@@ -3,7 +3,7 @@
PLATFORM=$(shell $(ROOT)/systype.sh)
include $(ROOT)/Make.defines.$(PLATFORM)
RPATH += -Wl,-rpath=$(ROOT)/lib:$(DEST)/lib
#RPATH += -Wl,-rpath=$(ROOT)/lib:$(DEST)/lib
# 开源工具包路径
LDDIR += -L$(DEST)/lib
test_net_socket/test_net_mod_socket.c
@@ -87,8 +87,8 @@
        
          if (fgets(content, MAXLINE, stdin) != NULL) {
              // 收到消息的节点即使没有对应的信息, 也要回复一个表示无的消息,否则会一直等待
            n = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, content,
          strlen(content), &recv_arr, &recv_arr_size, 5000);
            n = net_mod_socket_sendandrecv(client, node_arr, node_arr_size, content,
          strlen(content), &recv_arr, &recv_arr_size);
            printf("send %d nodes\n", n);
            for(i=0; i<recv_arr_size; i++) {
                printf("host:%s, port: %d, key:%d, content: %s\n",