Skip to content
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

开启KCP后,改变udp的目标发送地址会无法正常通讯 #523

Open
firemeatman opened this issue Apr 15, 2024 · 0 comments
Open

Comments

@firemeatman
Copy link

当我开启KCP后,我想通过udpClient给多个主机发送消息,但是我发现中途改变hio的目标地址会造成通讯异常。

下面这段代码中,我用定时器定时向服务器发送消息,每次都重新设置sendto的目标地址。但这会造成服务端那边只收到一次消息,后面的消息都收不到。如果不改变sendto的目标地址就不会发生这种情况。

    GlobalData::udpClient.loop()->setInterval(3000, [](hv::TimerID timerID) {
        sockaddr_u target_sockaddr;
        sockaddr_set_ipport(&target_sockaddr, "服务器地址", 1240);
        int res = GlobalData::udpClient.sendto("test msg!!!", &(target_sockaddr.sa));
        qDebug("send udp res: %d", res);
    });

如果这个不是bug,那么我是不是要像TCP一样,每次与不同的主机通讯的时候,我都要为每个地址都创建套接字才行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant