-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
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
udp数据可能被误读 #216
Comments
可能 所以后面代码做了判断: 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);
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在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: