public static void bind(ServerSocket srv_sock, InetAddress bind_addr, int start_port, int end_port) throws Exception { bind(srv_sock, bind_addr, start_port, end_port, 50); }
public static void bind(final ServerSocketChannel ch, InetAddress bind_addr, int start_port, int end_port) throws Exception { bind(ch, bind_addr, start_port, end_port, 50); }
public static ServerSocketChannel createServerSocketChannelAndBind(InetAddress bind_addr, int start_port, int end_port) throws Exception { ServerSocketChannel channel=ServerSocketChannel.open(); bind(channel, bind_addr, start_port, end_port); return channel; }
protected static int getNextTCPPort(InetAddress bind_addr, int start_port) throws Exception { try(ServerSocket sock=new ServerSocket()) { sock.setReuseAddress(false); Util.bind(sock, bind_addr, start_port, start_port+100); return sock.getLocalPort(); } }
public static ServerSocket createServerSocket(SocketFactory factory, String service_name, InetAddress bind_addr, int start_port) { ServerSocket ret=null; try { ret=factory.createServerSocket(service_name); Util.bind(ret, bind_addr, start_port, start_port+1000, 50); return ret; } catch(Exception e) { return null; } }
/** * Finds first available port starting at start_port and returns server * socket. Will not bind to port >end_port. Sets srv_port */ public static ServerSocket createServerSocketAndBind(SocketFactory factory,String service_name,InetAddress bind_addr, int start_port,int end_port) throws Exception { ServerSocket ret=factory.createServerSocket(service_name); bind(ret, bind_addr, start_port, end_port); return ret; }
/** * Creates a socket to {@code dest}, and assigns it to ping_sock. Also assigns ping_input */ protected boolean setupPingSocket(IpAddress dest) { lock.lock(); try { SocketAddress destAddr=new InetSocketAddress(dest.getIpAddress(), dest.getPort()); ping_sock=getSocketFactory().createSocket("jgroups.fd.ping_sock"); Util.bind(ping_sock, bind_addr, client_bind_port, client_bind_port+port_range); ping_sock.setSoLinger(true, 1); ping_sock.setKeepAlive(keep_alive); Util.connect(ping_sock, destAddr, sock_conn_timeout); ping_input=ping_sock.getInputStream(); return true; } catch(Throwable ex) { if(!shuttin_down) log.debug("%s: failed connecting to %s: %s", local_addr, ping_dest != null? ping_dest : dest, ex.getMessage()); return false; } finally { lock.unlock(); } }
public static void bind(ServerSocket srv_sock, InetAddress bind_addr, int start_port, int end_port) throws Exception { bind(srv_sock, bind_addr, start_port, end_port, 50); }
public static void bind(final ServerSocketChannel ch, InetAddress bind_addr, int start_port, int end_port) throws Exception { bind(ch, bind_addr, start_port, end_port, 50); }
public static ServerSocketChannel createServerSocketChannelAndBind(InetAddress bind_addr, int start_port, int end_port) throws Exception { ServerSocketChannel channel=ServerSocketChannel.open(); bind(channel, bind_addr, start_port, end_port); return channel; }
protected static int getNextTCPPort(InetAddress bind_addr, int start_port) throws Exception { try(ServerSocket sock=new ServerSocket()) { sock.setReuseAddress(false); Util.bind(sock, bind_addr, start_port, start_port+100); return sock.getLocalPort(); } }
public static ServerSocket createServerSocket(SocketFactory factory, String service_name, InetAddress bind_addr, int start_port) { ServerSocket ret=null; try { ret=factory.createServerSocket(service_name); Util.bind(ret, bind_addr, start_port, start_port+1000, 50); return ret; } catch(Exception e) { return null; } }
/** * Finds first available port starting at start_port and returns server * socket. Will not bind to port >end_port. Sets srv_port */ public static ServerSocket createServerSocketAndBind(SocketFactory factory,String service_name,InetAddress bind_addr, int start_port,int end_port) throws Exception { ServerSocket ret=factory.createServerSocket(service_name); bind(ret, bind_addr, start_port, end_port); return ret; }
/** * Creates a socket to {@code dest}, and assigns it to ping_sock. Also assigns ping_input */ protected boolean setupPingSocket(IpAddress dest) { lock.lock(); try { SocketAddress destAddr=new InetSocketAddress(dest.getIpAddress(), dest.getPort()); ping_sock=getSocketFactory().createSocket("jgroups.fd.ping_sock"); Util.bind(ping_sock, bind_addr, client_bind_port, client_bind_port+port_range); ping_sock.setSoLinger(true, 1); ping_sock.setKeepAlive(keep_alive); Util.connect(ping_sock, destAddr, sock_conn_timeout); ping_input=ping_sock.getInputStream(); return true; } catch(Throwable ex) { if(!shuttin_down) log.debug("%s: failed connecting to %s: %s", local_addr, ping_dest != null? ping_dest : dest, ex.getMessage()); return false; } finally { lock.unlock(); } }