Libraryless. Click here for Pure Java version (1112L/8K/27K).
!747 m { static long timeout = 5000; p { final S pivot = randomID(6); new L<S> 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(); } }
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001225 |
Snippet name: | Check my host name(s) by contacting myself |
Eternal ID of this version: | #1001225/1 |
Text MD5: | eaaca8ecf72fb48519d43cc31fece3f6 |
Transpilation MD5: | 0021a390c243377a5151c440f1bb4a13 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-03 19:25:19 |
Source code size: | 1930 bytes / 70 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 600 / 660 |
Referenced in: | [show references] |