Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1001197 // Native Ping! (should work everywhere)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (3896L/27K).

1  
!7
2  
3  
static S ip = "tinybrain.de" /*"127.0.0.1"*/;
4  
static int count = 2;
5  
static boolean result;
6  
7  
p {
8  
  // Java has trouble executing pings, so we use the native command.
9  
  
10  
  S cmd = "ping " + (isWindows() ? "-n" : "-c") + " " + count + " " + ip;
11  
  S output = backtick(cmd);
12  
  print(output);
13  
  
14  
  L<S> tok = javaTok(output);
15  
  int i = findCodeTokens(tok, "ttl", "=");
16  
  if (i < 0) i = findCodeTokens(tok, "TTL", "=");
17  
  result = i >= 0;
18  
  print(result ? ip + " is reachable." : ip + " is not reachable.");
19  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1108 stefan Works on Linux + Windows. Android to test 2015-09-29 19:56:34

add comment

Snippet ID: #1001197
Snippet name: Native Ping! (should work everywhere)
Eternal ID of this version: #1001197/2
Text MD5: fb0d800c090b82c44af1b38c00f27c54
Transpilation MD5: 391f83836cfc55f6f3576a3cf7912a2a
Author: stefan
Category: javax networking
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-18 12:44:26
Source code size: 526 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 908 / 1435
Version history: 1 change(s)
Referenced in: [show references]