@Override public DatagramChannelConfig setReuseAddress(boolean reuseAddress) { try { javaSocket.setReuseAddress(reuseAddress); } catch (SocketException e) { throw new ChannelException(e); } return this; }
@Override public DatagramChannelConfig setReuseAddress(boolean reuseAddress) { try { javaSocket.setReuseAddress(reuseAddress); } catch (SocketException e) { throw new ChannelException(e); } return this; }
@Override public DatagramChannelConfig setReuseAddress(boolean reuseAddress) { try { javaSocket.setReuseAddress(reuseAddress); } catch (SocketException e) { throw new ChannelException(e); } return this; }
/** * Checks to see if a specific port is available. * * @param port the port to check for availability */ public static boolean checkPortAvailable(int port) { try(ServerSocket ss = new ServerSocket(port); DatagramSocket ds = new DatagramSocket(port); ) { ss.setReuseAddress(true); ds.setReuseAddress(true); return true; } catch (IOException e) { logger.error("Exception in checking port, should be ignored."); } return false; } }
ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException e) {
public void setReuseAddress(boolean reuseAddress) { try { socket.setReuseAddress(reuseAddress); } catch (SocketException e) { throw new ChannelException(e); } }
ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException e) {
ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException e) {
ss.setReuseAddress( true ); ds = new DatagramSocket( port ); ds.setReuseAddress( true ); return true;
ds.setReuseAddress( true ); ds.bind(new InetSocketAddress((InetAddress) null, port)); logger.info("port {} available", port);
ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException e) {
/** * Checks to see if a specific port is available. * * @param port the port number to check for availability * @return {@code true} if the port is available, or {@code false} if not * @throws IllegalArgumentException is thrown if the port number is out of range */ public static synchronized boolean available(final int port) throws IllegalArgumentException { if (port < currentMinPort.get() || port > MAX_PORT_NUMBER) { throw new IllegalArgumentException("Invalid start currentMinPort: " + port); } ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (final IOException e) { // Do nothing } finally { Closer.closeSilently(ds); Closer.closeSilently(ss); } return false; }
_udpSocket.socket().setReuseAddress(true); InetSocketAddress isa = new InetSocketAddress(H2O.SELF_ADDRESS, H2O_PORT); _udpSocket.socket().bind(isa);
/** {@inheritDoc} */ public MulticastMessageChannel createUdpServer(final InetSocketAddress bindAddress, final ChannelListener<? super MulticastMessageChannel> bindListener, final OptionMap optionMap) throws IOException { checkShutdown(); final DatagramChannel channel; if (bindAddress != null) { InetAddress address = bindAddress.getAddress(); if (address instanceof Inet6Address) { channel = DatagramChannel.open(StandardProtocolFamily.INET6); } else { channel = DatagramChannel.open(StandardProtocolFamily.INET); } } else { channel = DatagramChannel.open(); } channel.configureBlocking(false); if (optionMap.contains(Options.BROADCAST)) channel.socket().setBroadcast(optionMap.get(Options.BROADCAST, false)); if (optionMap.contains(Options.IP_TRAFFIC_CLASS)) channel.socket().setTrafficClass(optionMap.get(Options.IP_TRAFFIC_CLASS, -1)); if (optionMap.contains(Options.RECEIVE_BUFFER)) channel.socket().setReceiveBufferSize(optionMap.get(Options.RECEIVE_BUFFER, -1)); channel.socket().setReuseAddress(optionMap.get(Options.REUSE_ADDRESSES, true)); if (optionMap.contains(Options.SEND_BUFFER)) channel.socket().setSendBufferSize(optionMap.get(Options.SEND_BUFFER, -1)); channel.socket().bind(bindAddress); final NioUdpChannel udpChannel = new NioUdpChannel(this, channel); ChannelListeners.invokeChannelListener(udpChannel, bindListener); return udpChannel; }
ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException e) {
public boolean open(int bindPort) { close(); try { InetSocketAddress bindSock = new InetSocketAddress(bindPort); ssdpUniSock = new DatagramSocket(null); ssdpUniSock.setReuseAddress(true); ssdpUniSock.bind(bindSock); } catch (Exception e) { //Debug.warning(e); return false; } return true; }
/** * {@inheritDoc} */ @Override public void bind(final SocketAddress localAddress) { if (localAddress == null) { // We should at least have one address to bind on throw new IllegalArgumentException("LocalAdress cannot be null"); } // check if the address is already bound if (this.address != null) { throw new IllegalStateException("address " + address + " already bound"); } address = localAddress; LOG.info("binding address {}", localAddress); try { datagramChannel = DatagramChannel.open(); datagramChannel.socket().setReuseAddress(isReuseAddress()); datagramChannel.socket().bind(address); datagramChannel.configureBlocking(false); } catch (IOException e) { throw new MinaRuntimeException("can't open the address " + address, e); } readSelectorLoop.register(false, false, true, false, this, datagramChannel, null); // it's the first address bound, let's fire the event this.fireServiceActivated(); }
channel.socket().setReuseAddress(reuseAddress);
DatagramSocket s = new DatagramSocket(null); s.setReuseAddress(true); s.bind(new InetSocketAddress("127.0.0.1", port)); s = new DatagramSocket(null); s.setReuseAddress(true); s.bind(new InetSocketAddress("localhost", port));
DatagramSocket s = new DatagramSocket(null); s.bind(new InetSocketAddress("127.0.0.1", port)); s = new DatagramSocket(null); s.setReuseAddress(true); s.bind(new InetSocketAddress("localhost", port));