简体   繁体   中英

UDP sockets bound to the same port

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM