default ServerSocketChannel createServerSocketChannel(String service_name, int port, int backlog) throws IOException { return createServerSocketChannel(service_name).bind(new InetSocketAddress(port), backlog); }
default ServerSocketChannel createServerSocketChannel(String service_name, int port, int backlog, InetAddress bindAddr) throws IOException { return createServerSocketChannel(service_name).bind(new InetSocketAddress(bindAddr, port), backlog); }
default ServerSocketChannel createServerSocketChannel(String service_name, int port) throws IOException { return createServerSocketChannel(service_name).bind(new InetSocketAddress(port)); }
public static ServerSocketChannel createServerSocketChannel(SocketFactory factory,String service_name, InetAddress bind_addr, int start_port, int end_port) throws Exception { int original_start_port=start_port; ServerSocketChannel ch=null; while(true) { try { if(ch != null) Util.close(ch); ch=factory.createServerSocketChannel(service_name); ch.bind(new InetSocketAddress(bind_addr, start_port), 50); return ch; } catch(SocketException bind_ex) { if(start_port == end_port) throw new BindException("No available port to bind to in range [" + original_start_port + " .. " + end_port + "]"); if(bind_addr != null && !bind_addr.isLoopbackAddress()) { NetworkInterface nic=NetworkInterface.getByInetAddress(bind_addr); if(nic == null) throw new BindException("bind_addr " + bind_addr + " is not a valid interface: " + bind_ex); } start_port++; } } }
default ServerSocketChannel createServerSocketChannel(String service_name, int port, int backlog, InetAddress bindAddr) throws IOException { return createServerSocketChannel(service_name).bind(new InetSocketAddress(bindAddr, port), backlog); }
default ServerSocketChannel createServerSocketChannel(String service_name, int port) throws IOException { return createServerSocketChannel(service_name).bind(new InetSocketAddress(port)); }
default ServerSocketChannel createServerSocketChannel(String service_name, int port, int backlog) throws IOException { return createServerSocketChannel(service_name).bind(new InetSocketAddress(port), backlog); }
public static ServerSocketChannel createServerSocketChannel(SocketFactory factory,String service_name, InetAddress bind_addr, int start_port, int end_port) throws Exception { int original_start_port=start_port; ServerSocketChannel ch=null; while(true) { try { if(ch != null) Util.close(ch); ch=factory.createServerSocketChannel(service_name); ch.bind(new InetSocketAddress(bind_addr, start_port), 50); return ch; } catch(SocketException bind_ex) { if(start_port == end_port) throw new BindException("No available port to bind to in range [" + original_start_port + " .. " + end_port + "]"); if(bind_addr != null && !bind_addr.isLoopbackAddress()) { NetworkInterface nic=NetworkInterface.getByInetAddress(bind_addr); if(nic == null) throw new BindException("bind_addr " + bind_addr + " is not a valid interface: " + bind_ex); } start_port++; } } }