Fu Juntang
2021-08-30 b861de29176891657cc96631ddbfb4ea9e114a42
src/net/net_mod_socket.cpp
@@ -22,7 +22,7 @@
NetModSocket::~NetModSocket() {
}
@@ -46,6 +46,15 @@
  return shmModSocket.force_bind(key);
}
int NetModSocket::bind_proc_id(char *buf, int len) {
  return shmModSocket.bind_proc_id(buf, len);
}
int NetModSocket::reg(void *pData, int len, void **buf, int *size, const int timeout_ms, int flag) {
  return shmModSocket.reg(pData, len, buf, size, timeout_ms, flag);
}
// 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) {
//   return _sendandrecv_(node_arr,  arrlen, send_buf,send_size, recv_arr, recv_arr_size, -1);
@@ -67,7 +76,7 @@
  NetConnPool *mpool = (NetConnPool *)_pool;
  delete mpool;
  logger->debug("destory connPool");
}
 /* One-time key creation function */
@@ -343,9 +352,6 @@
  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, const char *topic, int topic_size, const void *content,
 int content_size, int  msec) {
  int i, connfd;
@@ -363,7 +369,7 @@
  net_mod_err_t err_msg;
  // 本地发送
  if(node_arr == NULL || arrlen == 0) {
  if ((node_arr == NULL) || (arrlen == 0)) {
    if(msec == 0) {
      ret = shmModSocket.pub(topic, topic_size, content, content_size, SHM_BUS_KEY,  NULL, BUS_NOWAIT_FLAG);
    } else if(msec > 0) {
@@ -525,7 +531,6 @@
int NetModSocket::recvfrom_nowait(void **buf, int *size, int *key){
  return shmModSocket.recvfrom(buf, size, key, NULL, BUS_NOWAIT_FLAG);
}
int NetModSocket::recvandsend(recvandsend_callback_fn callback,
                              const struct timespec *timeout , int flag, void * user_data ) {
@@ -764,23 +769,23 @@
  head.mod = ntohl(GET(tmp_ptr));
  tmp_ptr += 4;
  tmp_ptr += sizeof(uint32_t);
  memcpy(head.host, tmp_ptr, sizeof(head.host));
 
  tmp_ptr += sizeof(head.host);
  head.port = ntohl(GET(tmp_ptr));
  tmp_ptr += 4;
  tmp_ptr += sizeof(uint32_t);
  head.key = ntohl(GET(tmp_ptr));
  tmp_ptr += 4;
  tmp_ptr += sizeof(uint32_t);
  head.content_length = ntohl(GET(tmp_ptr));
  tmp_ptr += 4;
  tmp_ptr += sizeof(uint32_t);
  head.topic_length = ntohl(GET(tmp_ptr));
  tmp_ptr += 4;
  tmp_ptr += sizeof(uint32_t);
  head.timeout = ntohl(GET_INT32(tmp_ptr));
 
  return head;