We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在UdpServer.cpp中,UdpServer在接收到对端发送的首个数据后,会根据本地地址和对端地址创建新的socket。在创建新socket的时候首先执行bindUdpSock,在bindPeerAddr之前的这一瞬间会不会接收其他对端的数据包? 从我当前的程序看是存在这种情况的。 运行环境:debian11 使用地址:127.0.0.1 测试方式:1个UdpServer,500个udp client同时发送数据
lock_guard<std::recursive_mutex> lck(*_session_mutex); auto it = _session_map->find(id); if (it != _session_map->end()) { return it->second; } assert(_socket); socket->bindUdpSock(_socket->get_local_port(), _socket->get_local_ip()); socket->bindPeerAddr((struct sockaddr *) addr_str.data(), addr_str.size()); auto helper = _session_alloc(server, socket); helper->session()->attachServer(*this);
The text was updated successfully, but these errors were encountered:
可能 所以后面代码做了判断:
socket->setOnRead([weak_self, weak_helper, id](const Buffer::Ptr &buf, struct sockaddr *addr, int addr_len) { auto strong_self = weak_self.lock(); if (!strong_self) { return; } //快速判断是否为本会话的的数据, 通常应该成立 if (id == makeSockId(addr, addr_len)) { if (auto strong_helper = weak_helper.lock()) { emitSessionRecv(strong_helper, buf); } return; } //收到非本peer fd的数据,让server去派发此数据到合适的session对象 strong_self->onRead_l(false, id, buf, addr, addr_len); });
Sorry, something went wrong.
No branches or pull requests
在UdpServer.cpp中,UdpServer在接收到对端发送的首个数据后,会根据本地地址和对端地址创建新的socket。在创建新socket的时候首先执行bindUdpSock,在bindPeerAddr之前的这一瞬间会不会接收其他对端的数据包?
从我当前的程序看是存在这种情况的。
运行环境:debian11
使用地址:127.0.0.1
测试方式:1个UdpServer,500个udp client同时发送数据
The text was updated successfully, but these errors were encountered: