aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Multicasting with Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Multicasting with Java?" Watch "Multicasting with Java?" New topic
Author

Multicasting with Java?

Andrew Wisner
Greenhorn

Joined: Aug 07, 2012
Posts: 4
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?


Andrew Wisner
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Hi Andrew, welcome to CodeRanch!

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.
Andrew Wisner
Greenhorn

Joined: Aug 07, 2012
Posts: 4
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multicasting with Java?