List of usage examples for java.net MulticastSocket send
@Deprecated public void send(DatagramPacket p, byte ttl) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { int port = 0; byte ttl = (byte) 1; byte[] data = "Here's some multicast data\r\n".getBytes(); DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("google.com"), port); MulticastSocket ms = new MulticastSocket(InetSocketAddress.createUnresolved("google.com", 8080)); ms.joinGroup(InetSocketAddress.createUnresolved("127.0.0.1", 8080), NetworkInterface.getByIndex(0)); for (int i = 1; i < 10; i++) { ms.send(dp, ttl); }//from ww w . j a v a2s . co m ms.setNetworkInterface(NetworkInterface.getByIndex(0)); ms.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { int port = 0; byte ttl = (byte) 1; byte[] data = "Here's some multicast data\r\n".getBytes(); DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("google.com"), port); MulticastSocket ms = new MulticastSocket(InetSocketAddress.createUnresolved("google.com", 8080)); ms.joinGroup(InetSocketAddress.createUnresolved("127.0.0.1", 8080), NetworkInterface.getByIndex(0)); for (int i = 1; i < 10; i++) { ms.send(dp, ttl); }/*from w ww . j a va2 s.c o m*/ ms.setTimeToLive(1000); ms.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { int port = 0; byte ttl = (byte) 1; byte[] data = "Here's some multicast data\r\n".getBytes(); DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("google.com"), port); MulticastSocket ms = new MulticastSocket(InetSocketAddress.createUnresolved("google.com", 8080)); ms.joinGroup(InetSocketAddress.createUnresolved("127.0.0.1", 8080), NetworkInterface.getByIndex(0)); for (int i = 1; i < 10; i++) { ms.send(dp, ttl); }/*from ww w. j a v a 2 s . com*/ ms.leaveGroup(InetSocketAddress.createUnresolved("java2s.com", 8080), NetworkInterface.getByIndex(0)); ms.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { int port = 0; byte ttl = (byte) 1; byte[] data = "Here's some multicast data\r\n".getBytes(); DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("google.com"), port); MulticastSocket ms = new MulticastSocket(InetSocketAddress.createUnresolved("google.com", 8080)); ms.joinGroup(InetSocketAddress.createUnresolved("127.0.0.1", 8080), NetworkInterface.getByIndex(0)); for (int i = 1; i < 10; i++) { ms.send(dp, ttl); }//from w w w .j a v a 2s. c o m ms.setInterface(InetAddress.getByName("google.com")); ms.close(); }