1 10 11 package org.mule.providers.multicast; 12 13 import org.mule.providers.udp.UdpMessageDispatcher; 14 import org.mule.umo.endpoint.UMOImmutableEndpoint; 15 16 import java.io.IOException ; 17 import java.net.DatagramSocket ; 18 import java.net.InetAddress ; 19 import java.net.MulticastSocket ; 20 21 27 28 public class MulticastMessageDispatcher extends UdpMessageDispatcher 29 { 30 public MulticastMessageDispatcher(UMOImmutableEndpoint endpoint) 31 { 32 super(endpoint); 33 } 34 35 protected DatagramSocket createSocket(int port, InetAddress inetAddress) throws IOException 36 { 37 MulticastSocket socket = new MulticastSocket (port); 38 socket.setLoopbackMode(((MulticastConnector)connector).isLoopback()); 39 socket.setReceiveBufferSize(connector.getBufferSize()); 41 socket.setSendBufferSize(connector.getBufferSize()); 42 socket.joinGroup(inetAddress); 43 return socket; 44 } 45 46 protected void doDisconnect() throws Exception 47 { 48 try 49 { 50 if (socket != null) 51 { 52 ((MulticastSocket )socket).leaveGroup(inetAddress); 53 } 54 } 55 catch (IOException e) 56 { 57 logger.error("Failed to leave group: " + inetAddress); 58 } 59 super.doDisconnect(); 60 } 61 } 62 | Popular Tags |