@Override public DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<DatagramSocket>> handler) { try { addListener(channel.joinGroup(InetAddress.getByName(multicastAddress)), handler); } catch (UnknownHostException e) { notifyException(handler, e); } return this; }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { connection.init(ctx.channel(), false); if (multicastAddress != null) { ((DatagramChannel) ctx.channel()).joinGroup(multicastAddress, networkInterface, null).addListener(future -> { if (future.isSuccess()) { LOGGER.info("join multicast group success, channel={}, group={}", ctx.channel(), multicastAddress); } else { LOGGER.error("join multicast group error, channel={}, group={}", ctx.channel(), multicastAddress, future.cause()); } }); } LOGGER.info("init udp channel={}", ctx.channel()); }
@Override public DatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<DatagramSocket>> handler) { try { InetAddress sourceAddress; if (source == null) { sourceAddress = null; } else { sourceAddress = InetAddress.getByName(source); } addListener(channel.joinGroup(InetAddress.getByName(multicastAddress), NetworkInterface.getByName(networkInterface), sourceAddress), handler); } catch (Exception e) { notifyException(handler, e); } return this; }
clientChannel = (DatagramChannel) f.channel(); log.info("{} joining multicast group {} on port {}", localAddress.getHostName(), groupAddress.getHostName(), groupAddress.getPort()); clientChannel.joinGroup(groupAddress, iface).addListener(f2 -> { if (f2.isSuccess()) { log.info("{} successfully joined multicast group {} on port {}", localAddress.getHostName(), groupAddress.getHostName(), groupAddress.getPort());
@Override public DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<DatagramSocket>> handler) { try { addListener(channel.joinGroup(InetAddress.getByName(multicastAddress)), handler); } catch (UnknownHostException e) { notifyException(handler, e); } return this; }
@Override public DatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<DatagramSocket>> handler) { try { InetAddress sourceAddress; if (source == null) { sourceAddress = null; } else { sourceAddress = InetAddress.getByName(source); } addListener(channel.joinGroup(InetAddress.getByName(multicastAddress), NetworkInterface.getByName(networkInterface), sourceAddress), handler); } catch (Exception e) { notifyException(handler, e); } return this; }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * @return a {@link Publisher} that will be complete when the group has been joined */ public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == channel) { throw new IllegalStateException("UdpServer not running."); } if (null == iface && null != getMulticastInterface()) { iface = getMulticastInterface(); } final ChannelFuture future; if (null != iface) { future = channel.joinGroup(new InetSocketAddress(multicastAddress, getListenAddress().getPort()), iface); } else { future = channel.joinGroup(multicastAddress); } return new MonoChannelFuture<Future<?>>(future){ @Override protected void doComplete(Future<?> future, Subscriber<? super Void> s) { log.info("JOIN {}", multicastAddress); super.doComplete(future, s); } }; }
clientChannel = (DatagramChannel) f.channel(); log.info("{} joining multicast group {} on port {}", localAddress.getHostName(), groupAddress.getHostName(), groupAddress.getPort()); clientChannel.joinGroup(groupAddress, iface).addListener(f2 -> { if (f2.isSuccess()) { log.info("{} successfully joined multicast group {} on port {}", localAddress.getHostName(), groupAddress.getHostName(), groupAddress.getPort());
@Override public Promise<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == channel) { throw new IllegalStateException("DatagramServer not running."); } final Promise<Void> d = Promises.ready(getDefaultEnvironment(), getDefaultDispatcher()); if (null == iface && null != getMulticastInterface()) { iface = getMulticastInterface(); } final ChannelFuture future; if (null != iface) { future = channel.joinGroup(new InetSocketAddress(multicastAddress, getListenAddress().getPort()), iface); } else { future = channel.joinGroup(multicastAddress); } future.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { log.info("JOIN {}", multicastAddress); if (future.isSuccess()) { d.onComplete(); } else { d.onError(future.cause()); } } }); return d; }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * * @return a {@link Publisher} that will be complete when the group has been joined */ @Override public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.joinGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info("JOIN {}", multicastAddress)); }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * * @return a {@link Publisher} that will be complete when the group has been joined */ @Override public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.joinGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info(format(future.channel(), "JOIN {}"), multicastAddress)); }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * * @return a {@link Publisher} that will be complete when the group has been joined */ @Override public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.joinGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info(format(future.channel(), "JOIN {}"), multicastAddress)); }
InetSocketAddress groupAddress = SocketUtils.socketAddress(group, addr.getPort()); cc.joinGroup(groupAddress, NetUtil.LOOPBACK_IF).sync();
ObjectHelper.notNull(multicastNetworkInterface, "No network interface found for '" + networkInterface + "'."); LOG.info("ConnectionlessBootstrap joining {}:{} using network interface: {}", configuration.getHost(), configuration.getPort(), multicastNetworkInterface.getName()); datagramChannel.joinGroup(hostAddress, multicastNetworkInterface).syncUninterruptibly(); allChannels.add(datagramChannel); } else {