简体   繁体   中英

Is it possible to set a DatagramSocket to receive from any other IP-Address?

In my application, I have a DatagramSocket . I want to set the socket so that it will receive DatagramPackets from any IP-Address, and not have to specify one. Would this be possible at all?

I have a list of EndPoints I want to send data to at some point, and expect the messages sent to me to come from these addresses, but I don't want to iterate through this list and individually receive packets.

Is there any way I can achieve this? I've done some extensive searches, but I can't seem to find a suitable answer...

That is the default behavior of sockets, you shouldn't have to worry about being limited to any particular IP address. Don't connect() the socket, just call receive() .

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