protected PhysicalAddress getPhysicalAddress() { return server != null? (PhysicalAddress)server.localAddress() : null; } }
/** * Creates an instance of {@link NioServer} that opens a server channel and listens for connections. * Needs to be started next. * @param thread_factory The thread factory used to create new threads * @param socket_factory The socket factory used to create socket channels * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param srv_port The local port to bind to If 0, the port will be picked by the OS. * @param end_port If srv_port is taken, the next port is tried, until end_port has been reached, in which case an * exception will be thrown. If srv_port == end_port, only 1 port will be tried. * @param external_addr The external address in case of NAT. Ignored if null. * @param external_port The external port on the NA. If 0, srv_port is used. * @throws Exception Thrown if the creation failed */ public NioServer(ThreadFactory thread_factory, SocketFactory socket_factory, InetAddress bind_addr, int srv_port, int end_port, InetAddress external_addr, int external_port) throws Exception { super(thread_factory, socket_factory); // channel=this.socket_factory.createServerSocketChannel("jgroups.nio.server"); // channel.setOption(StandardSocketOptions.SO_REUSEADDR, reuse_addr); // Util.bind(channel, bind_addr, srv_port, end_port); channel=Util.createServerSocketChannel(this.socket_factory, "jgroups.nio.server", bind_addr, srv_port, end_port); channel.configureBlocking(false); selector=Selector.open(); acceptor=factory.newThread(new Acceptor(), "NioServer.Selector [" + channel.getLocalAddress() + "]"); channel.register(selector, SelectionKey.OP_ACCEPT, null); local_addr=localAddress(bind_addr, channel.socket().getLocalPort(), external_addr, external_port); }
protected PhysicalAddress getPhysicalAddress() { return server != null? (PhysicalAddress)server.localAddress() : null; } }
/** * Creates an instance of {@link NioServer} that opens a server channel and listens for connections. * Needs to be started next. * @param thread_factory The thread factory used to create new threads * @param socket_factory The socket factory used to create socket channels * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param srv_port The local port to bind to If 0, the port will be picked by the OS. * @param end_port If srv_port is taken, the next port is tried, until end_port has been reached, in which case an * exception will be thrown. If srv_port == end_port, only 1 port will be tried. * @param external_addr The external address in case of NAT. Ignored if null. * @param external_port The external port on the NA. If 0, srv_port is used. * @throws Exception Thrown if the creation failed */ public NioServer(ThreadFactory thread_factory, SocketFactory socket_factory, InetAddress bind_addr, int srv_port, int end_port, InetAddress external_addr, int external_port) throws Exception { super(thread_factory, socket_factory); // channel=this.socket_factory.createServerSocketChannel("jgroups.nio.server"); // channel.setOption(StandardSocketOptions.SO_REUSEADDR, reuse_addr); // Util.bind(channel, bind_addr, srv_port, end_port); channel=Util.createServerSocketChannel(this.socket_factory, "jgroups.nio.server", bind_addr, srv_port, end_port); channel.configureBlocking(false); selector=Selector.open(); acceptor=factory.newThread(new Acceptor(), "NioServer.Selector [" + channel.getLocalAddress() + "]"); channel.register(selector, SelectionKey.OP_ACCEPT, null); local_addr=localAddress(bind_addr, channel.socket().getLocalPort(), external_addr, external_port); }