/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
protected void startPeerServer(int i) throws IOException { peerServers[i] = new NioServer(new StreamConnectionFactory() { @Nullable @Override public StreamConnection getNewConnection(InetAddress inetAddress, int port) { return new InboundMessageQueuer(PARAMS) { @Override public void connectionClosed() { } @Override public void connectionOpened() { newPeerWriteTargetQueue.offer(this); } }; } }, new InetSocketAddress("127.0.0.1", 2000 + i)); peerServers[i].startAsync(); peerServers[i].awaitRunning(); }