zhangmeng
2024-04-09 2561a007b8d8999a4750046d0cfb3b1ad5af50ac
src/net/net_mod_socket.cpp
@@ -46,13 +46,25 @@
  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);
}
void NetModSocket::int_set(int data) {
  int_val = data;
}
void NetModSocket::svr_set(int data) {
  svr_val = data;
}
int NetModSocket::int_get(void) {
  return int_val;
}
int NetModSocket::svr_get(void) {
  return svr_val;
}
// int NetModSocket::sendandrecv(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, 
@@ -109,7 +121,6 @@
  if (mpool == NULL)
  {
    /* If first call from this thread, allocate buffer for thread, and save its location */
    logger->debug("Create connPool");
    mpool = new NetConnPool();
    if (mpool == NULL) {
      LoggerFactory::getLogger()->error(errno, "NetModSocket::_sendandrecv_ malloc");
@@ -329,6 +340,29 @@
     
}
void NetModSocket::buf_data_set(std::string str, int val) {
  recvbuf.insert({str, val});
}
int NetModSocket::buf_data_get(std::string str) {
  int i;
  int val = 0;
  std::map<std::string, int>::iterator recvIter;
  recvIter = recvbuf.find(str);
  if(recvIter != recvbuf.end()) {
    val = recvIter->second;
  }
  return val;
}
void NetModSocket::buf_data_del(std::string str) {
  recvbuf.erase(str);
}
void NetModSocket::free_recv_msg_arr(net_mod_recv_msg_t * arr, size_t size) {
@@ -493,20 +527,20 @@
 * @key 发送给谁
 * @return 0 成功, 其他值 失败的错误码
 */
int NetModSocket::sendto(const void *buf, const int size, const int key){
  return shmModSocket.sendto(buf, size, key);
int NetModSocket::sendto(const void *buf, const int size, const int key, int reset, int data_set){
  return shmModSocket.sendto(buf, size, key, 0, 0, reset, data_set);
}
// 发送信息超时返回。 @sec 秒 , @nsec 纳秒
int NetModSocket::sendto_timeout(const void *buf, const int size, const int key, int sec, int nsec){
int NetModSocket::sendto_timeout(const void *buf, const int size, const int key, int sec, int nsec, int reset, int data_set){
  struct timespec timeout = {sec, nsec};
  return shmModSocket.sendto(buf, size, key, &timeout, BUS_TIMEOUT_FLAG);
  return shmModSocket.sendto(buf, size, key, &timeout, BUS_TIMEOUT_FLAG, reset, data_set);
   
}
// 发送信息立刻返回。
int NetModSocket::sendto_nowait(const void *buf, const int size, const int key){
  return shmModSocket.sendto(buf, size, key, NULL, BUS_NOWAIT_FLAG);
int NetModSocket::sendto_nowait(const void *buf, const int size, const int key, int reset, int data_set){
  return shmModSocket.sendto(buf, size, key, NULL, BUS_NOWAIT_FLAG, reset, data_set);
  
}
@@ -515,21 +549,21 @@
 * @key 从谁哪里收到的信息
 * @return 0 成功, 其他值 失败的错误码
*/
int NetModSocket::recvfrom(void **buf, int *size, int *key) {
int NetModSocket::recvfrom(void **buf, int *size, int *key, int reset, int data_set) {
  return shmModSocket.recvfrom(buf, size, key);
  return shmModSocket.recvfrom(buf, size, key, 0, 0, reset, data_set);
 
}
// 接受信息超时返回。 @sec 秒 , @nsec 纳秒
int NetModSocket::recvfrom_timeout(void **buf, int *size, int *key, int sec, int nsec){
int NetModSocket::recvfrom_timeout(void **buf, int *size, int *key, int sec, int nsec, int reset, int data_set){
  struct timespec timeout = {sec, nsec};
  return shmModSocket.recvfrom(buf, size, key, &timeout, BUS_TIMEOUT_FLAG);
  return shmModSocket.recvfrom(buf, size, key, &timeout, BUS_TIMEOUT_FLAG, reset, data_set);
  
}
int NetModSocket::recvfrom_nowait(void **buf, int *size, int *key){
  return shmModSocket.recvfrom(buf, size, key, NULL, BUS_NOWAIT_FLAG);
int NetModSocket::recvfrom_nowait(void **buf, int *size, int *key, int reset, int data_set){
  return shmModSocket.recvfrom(buf, size, key, NULL, BUS_NOWAIT_FLAG, reset, data_set);
}
int NetModSocket::recvandsend(recvandsend_callback_fn callback,