-// }
-//
-// // Clear keys for next select
-// keys.clear();
-// }
-//
-// }
-
-// public static void mainX(String[] args) throws IOException, InterruptedException {
-// toRawTerminal();
-// try {
-// boolean client = true;
-// if (client) {
-// ReadableByteChannel inChannel;
-// WritableByteChannel outChannel;
-// inChannel = Channels.newChannel(System.in);
-// outChannel = Channels.newChannel(System.out);
-//
-// SocketChannel channel = SocketChannel.open(StandardProtocolFamily.UNIX);
-// channel.connect(ioSocketAddress());
-//
-// new Thread(() -> {
-//
-// try {
-// ByteBuffer buffer = ByteBuffer.allocate(1024);
-// while (true) {
-// if (channel.read(buffer) < 0)
-// break;
-// buffer.flip();
-// outChannel.write(buffer);
-// buffer.rewind();
-// }
-// System.exit(0);
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-// }, "Read out").start();
-//
-// ByteBuffer buffer = ByteBuffer.allocate(1);
-// while (channel.isConnected()) {
-// if (inChannel.read(buffer) < 0)
-// break;
-// buffer.flip();
-// channel.write(buffer);
-// buffer.rewind();
-// }
-//
-// } else {
-// ServerSocketChannel serverChannel = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
-// serverChannel.bind(ioSocketAddress());
-//
-// SocketChannel channel = serverChannel.accept();
-//
-// while (true) {
-// readSocketMessage(channel).ifPresent(message -> System.out.printf("[Client message] %s", message));
-// Thread.sleep(100);
-// }
-// }
-// } finally {
-// toOriginalTerminal();
-// }
-// }
-//
-// private static Optional<String> readSocketMessage(SocketChannel channel) throws IOException {
-// ByteBuffer buffer = ByteBuffer.allocate(1024);
-// int bytesRead = channel.read(buffer);
-// if (bytesRead < 0)
-// return Optional.empty();
-//
-// byte[] bytes = new byte[bytesRead];
-// buffer.flip();
-// buffer.get(bytes);
-// String message = new String(bytes);
-// return Optional.of(message);
-// }
-//
-// public static void setupConnection(Selector selector, SocketChannel client) throws IOException {
-// // Connect to the remote server
-// SocketAddress address = new InetSocketAddress("192.168.1.74", 8000);
-// SocketChannel remote = SocketChannel.open(address);
-//
-// // Make sockets non-blocking (should be better performance)
-// client.configureBlocking(false);
-// remote.configureBlocking(false);
-//
-// client.register(selector, SelectionKey.OP_READ, remote);
-// remote.register(selector, SelectionKey.OP_READ, client);
-// }
-//
-// static UnixDomainSocketAddress ioSocketAddress() throws IOException {
-// String system = "default";
-// String bundleSn = "org.argeo.slc.jshell";
-//
-// String xdgRunDir = System.getenv("XDG_RUNTIME_DIR");
-// Path baseRunDir = Paths.get(xdgRunDir);
-// Path jshellSocketBase = baseRunDir.resolve("jshell").resolve(system).resolve(bundleSn);
-//
-// Files.createDirectories(jshellSocketBase);
-//
-// Path ioSocketPath = jshellSocketBase.resolve("io");
-//
-// UnixDomainSocketAddress ioSocketAddress = UnixDomainSocketAddress.of(ioSocketPath);
-// System.out.println(ioSocketAddress);
-// return ioSocketAddress;
-// }