멀티캐스트 방식은 단 한가지를 제외하고, UDP 방식과 똑같은 방식을 취하고 있다.
멀티캐스트 방식은 목적지를 멀티캐스트 그룹으로 지정한다는 점이다.
멀티캐스트를 구현하려면 라우터가 멀티캐스트 패킷라우팅을 지원해야하나, 대부분의 라우터가
패킷 라우팅을 지원하지 않기때문에 MBone이라는 실험용 멀티캐스트 프레임워크가 탄생하였다.
(멀티미디어 데이터들은 멀티캐스트가 지원되지 않는 인터넷엔 유니캐스트로 전송되다가, MBone에 도달하는 과정을 tunnel이라 부른다.)
멀티캐스팅을 이용하는것은 서버가 불특정 다수에게 정보를 전달한다.
DatagramSocket socket = null;
DatagramPacket packet = null;
InetAddress channel = null;
int port = 20001;
public MulticastServer() throws IOException{
super("멀티캐스트 방송국");
socket = new DatagramSocket(port);
}
public void run(){
String msg = "호호호호호호"
byte[] b = new byte[100];
while(onAir = true) {
b= msg.getBytes();
channel = InetAddress.getByName(address);
packet = new DatagramPacket(b, b.length , channel , port);
socket.send(packet);
}
}