jdk/src/share/sample/nio/multicast/Sender.java
changeset 9679 d98ae8bc45fc
parent 5506 202f599c92aa
child 10292 ed7db6a12c2a
equal deleted inserted replaced
9677:638762c0263e 9679:d98ae8bc45fc
    57         ProtocolFamily family = StandardProtocolFamily.INET;
    57         ProtocolFamily family = StandardProtocolFamily.INET;
    58         if (target.group() instanceof Inet6Address)
    58         if (target.group() instanceof Inet6Address)
    59             family = StandardProtocolFamily.INET6;
    59             family = StandardProtocolFamily.INET6;
    60         DatagramChannel dc = DatagramChannel.open(family).bind(new InetSocketAddress(0));
    60         DatagramChannel dc = DatagramChannel.open(family).bind(new InetSocketAddress(0));
    61         if (target.interf() != null) {
    61         if (target.interf() != null) {
    62             dc.setOption(StandardSocketOption.IP_MULTICAST_IF, target.interf());
    62             dc.setOption(StandardSocketOptions.IP_MULTICAST_IF, target.interf());
    63         }
    63         }
    64 
    64 
    65         // send multicast packet
    65         // send multicast packet
    66         dc.send(Charset.defaultCharset().encode(args[1]),
    66         dc.send(Charset.defaultCharset().encode(args[1]),
    67                 new InetSocketAddress(target.group(), target.port()));
    67                 new InetSocketAddress(target.group(), target.port()));