UDP 套接字绑定到同一端口
如果你有两个 udp 套接字,具有相同的端口,并且只有其中一个设置为仅接收来自特定 ip 的消息,我知道消息将随机传递到其中一个,但如果两者都设置为只接收来自不同ip的消息,使用connect,是否有消息丢失,因为它们会被发送到错误的套接字并被丢弃?
If you have two udp sockets, with the same port, and only one of them is set up to only receive messages from an specific ip, i know that a message will be delivered randomly to one of them, but if both are set up to only receive messages from different ips, with connect, does any message get lost because they will be sent to the wrong socket and discarded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
连接的 UDP 套接字只会从连接的对等方接收数据报。如果有两个套接字绑定到相同的地址(IP 和端口)但连接到不同的对等点,情况也是如此。因此,在您的情况下,任何消息都不会到达错误的套接字并在那里丢失。
A connected UDP socket will only receive datagrams from the connected peer. This is also true if there are two sockets bound to the same address (IP and port) but connected to different peers. Thus, in your case, no messages will end up at the wrong socket and get lost there.