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

16
LINES

< > BotCompany Repo | #1001332 // killPortAndWait

JavaX fragment (include)

1  
static void killPortAndWait(int port) {
2  
  killPortAndWait("localhost", port);
3  
}
4  
5  
static void killPortAndWait(S ip, int port) ctex {
6  
  print("Sending kill switch to " + ip + ":" + port);
7  
  DialogIO io = talkTo(ip, port);
8  
  io.sendLine("kill!");
9  
  try {
10  
    // wait until it is closed from other side
11  
    S s;
12  
    while ((s = io.readLine()) != null)
13  
      print(port + "< " + s);
14  
  } catch (Exception e) {}
15  
  io.close(); // never throws exceptions
16  
}

Author comment

Began life as a copy of #1001070

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: #1001332
Snippet name: killPortAndWait
Eternal ID of this version: #1001332/2
Text MD5: f942894578799e6b9336b163c8004945
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-14 11:09:08
Source code size: 462 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 713 / 1019
Version history: 1 change(s)
Referenced in: [show references]