!747 m { static long timeout = 5000; p { final S pivot = randomID(6); new L myNames; makeAndroid_forcePublic = true; makeAndroid_allowVMInspection = false; Android android = makeAndroid2("", stringfunc { pivot }, false); ServerSocket server = startDialogServer_serverSocket; for (S name : litlist("tinybrain.de", "second.tinybrain.de"/*, "google.de"*/)) { print("Checking " + name); boolean result = isItMe(name, android.port, pivot, timeout); print(" => " + result); if (result) myNames.add(name); } print("My names: " + structure(myNames)); server.close(); // TODO: close the client connections //sleepSeconds(2); //listUserThreadsWithStackTraces(); //System.exit(0); // SHOULD now exit properly by itself } !include #1000915 // Flag class static boolean isItMe(final String name, final int port, final S pivot, long timeout) { final new Flag ok; final new Flag done; Thread t = new Thread("Talking to " + name + ":" + port) { public void run() { try { DialogIO io = talkTo(name, port); print("Connected to " + name + ":" + port + "."); if (!io.waitForLine()) return; S line = io.readLineNoBlock(); io.sendLine("please give pivot"); if (!io.waitForLine()) return; line = io.readLineNoBlock(); print("Line read: " + quote(line)); io.close(); if (pivot.equals(line)) ok.raise(); } catch (RuntimeException e) { print("[internal] " + e); } finally { done.raise(); } } }; t.start(); done.waitUntilUp(timeout); print("Interrupting thread."); t.interrupt(); return ok.isUp(); } }