How can I send data to multiple IPs in VB.NET with TCP/IP sockets?
I have an array of IP addresses, and I want to send the same data to all of them. I could just send the loop code that sends data but I think there's a better way of doing this.
I've heard of multicast, what exactly is it? I think it's what I need but how do 开发者_JS百科i use it.
Yes, you can use multicast for this. Your sender just emits UDP packets to any address in the 224.x.x.x to 239.x.x.x range. Your receivers listen on the same address, and the underlying stack and network fabric figure out how to get the packets from sender to receiver.
Beware that this range is subdivided so that certain addresses will be more appropriate to your application than others. You might choose 239.x.x.x for a program that's only used on a single LAN, for instance.
Also beware that this only works with UDP -- there's no such thing as multicast TCP -- and that getting it to work across routers may be difficult. Getting it to work across the current Internet is especially difficult, since most ISPs don't support multicast.
精彩评论