wangzhengquan
2021-02-25 f52f2c2828047c2f30d30fc1fe2b54d8db146d49
src/socket/shm_mod_socket.cpp
@@ -3,13 +3,9 @@
static Logger *logger = LoggerFactory::getLogger();
size_t ShmModSocket::remove_keys(int keys[], size_t length) {
   BusServerSocket::remove_subscripters(keys, length);
   return shm_socket_remove_keys(keys, length);
}
ShmModSocket::ShmModSocket() {
   shm_socket = shm_open_socket(SHM_SOCKET_DGRAM);
   shm_socket = shm_socket_open(SHM_SOCKET_DGRAM);
   bus_set = new std::set<int>;
}
@@ -23,8 +19,13 @@
      delete bus_set;
   }
   shm_close_socket(shm_socket);
   shm_socket_close(shm_socket);
}
int ShmModSocket::stop() {
   return shm_socket_stop(shm_socket);
}
int ShmModSocket::bind(int key) {
   return  shm_socket_bind(shm_socket, key);
@@ -91,16 +92,9 @@
}
int ShmModSocket::recvandsend(void **recvbuf, int *recvsize, int *key, recv_callback_fn callback,
                    const struct timespec *timeout , int flag ) {
  int rv = shm_recvandsend(shm_socket, recvbuf, recvsize, key, callback, timeout, flag);
  if(rv == 0) {
    logger->debug("ShmModSocket::shm_recvandsend: success. key = %d\n", *key);
    return 0;
  }
  logger->debug("ShmModSocket::shm_recvandsend :  failed. %s", bus_strerror(rv));
  return rv;
int ShmModSocket::recvandsend( recvandsend_callback_fn callback,
                    const struct timespec *timeout , int flag, void * user_data ) {
  return shm_recvandsend(shm_socket, callback, timeout, flag, user_data);
}
 
// // 超时返回。 @sec 秒 , @nsec 纳秒