开发者

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

开发者 https://www.devze.com 2023-02-11 23:58 出处:网络
In my application, I have a DatagramSocket. I want to set开发者_如何学C the socket so that it will receive DatagramPackets from any IP-Address, and not have to specify one. Would this be possible at a

In my application, I have a DatagramSocket. I want to set开发者_如何学C 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().

0

精彩评论

暂无评论...
验证码 换一张
取 消