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

12
LINES

< > BotCompany Repo | #1000808 // isPortOpen

JavaX fragment (include)

static int isPortOpen_timeout = 500;
static boolean isPortOpen(int port) {
  try {
    Socket socket = new Socket();
    socket.connect(new InetSocketAddress("127.0.0.1", port), isPortOpen_timeout);
    //print("Connected to " + ip + ":" + port);
    socket.close();
    return true;
  } catch (Exception ex) {
    return false;
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000808
Snippet name: isPortOpen
Eternal ID of this version: #1000808/1
Text MD5: 66163546e21486a4beb1560b22c425cb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-28 19:12:42
Source code size: 345 bytes / 12 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 697 / 935
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1011746 - hasOpenPort
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)