I'm working on a Java server application that distributes a video feed to many Java clients. From my understanding, the best way to do this is with multicasting, and Java supports it. I understand the DatagramSocket/Packet objects, but I'm rather confused how exactly multicasting would work. My programming books/websites make it sound as though I simply pick a Class D IP address and bind both the server and the clients to it.
I have a tendency to over-complicate my algorithms, but this idea doesn't make any sense. It seems way to easy. How will the rest of the world know not to use the IP address I pick?
Can anyone suggest some (free) resources which might explain multicasting with Java better?
Multicast is like radio. In radio, a transmitter broadcasts the show over a frequency, and radios have to tune in to that frequency. The same thing happens with multicast. The sender sends packets to a multicast address, and all receivers that have registered with that address will get the packet (not taking reliability into account, which is a problem with UDP obviously).
It really is that simple. Now, the thing that's preventing other applications from interfering, is the same reason that multicast may not be the solution to your problem: hardware support. Multicast is implemented by having routers duplicate packages if they are sent to a multicast address. However, most routers only support this within a LAN, and do not send multicast packages into the internet. So while multicast is excellent within a local network, you probably shouldn't rely on it if you want to distribute content over the internet.
Joined: Aug 07, 2012
Thank you so much for your quick reply! Ideally, I need the application to stream video to clients outside the LAN. I'll take a look into some other technologies then.