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

34
LINES

< > BotCompany Repo | #1006483 // Swing Telnet

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

Libraryless. Click here for Pure Java version (3867L/27K/92K).

1  
!752
2  
3  
p-substance {
4  
  final JTextField tf1 = jTextField("localhost");
5  
  final JTextField tf2 = jTextField("4999");
6  
  showForm(
7  
    "Host", tf1,
8  
    "Port", tf2, r-thread {
9  
      connect(getTextTrim(tf1), parseInt(getTextTrim(tf2)));
10  
    });
11  
}
12  
13  
svoid connect(S host, int port) {
14  
  print("Connecting to " + host + ":" + port + "...");
15  
  final DialogIO io = talkTo(host, port);
16  
    
17  
  // output
18  
  thread {
19  
    S line;
20  
    while ((line = readLine()) != null)
21  
      io.sendLine(line);
22  
  }
23  
  
24  
  // input
25  
  while (io.isStillConnected()) {
26  
    if (io.waitForLine()) {
27  
      S line = io.readLineNoBlock();
28  
      print("> " + line);
29  
    }
30  
  }
31  
  
32  
  print();
33  
  print("[logout]");
34  
}

Author comment

Began life as a copy of #1001077

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006483
Snippet name: Swing Telnet
Eternal ID of this version: #1006483/1
Text MD5: e900e03224cf99fe3b9a9e8311f6b1de
Transpilation MD5: 87e0293bdd4a5c8352744e94b5f8743e
Author: stefan
Category: javax / networking / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-01-10 13:43:57
Source code size: 702 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 435 / 516
Referenced in: [show references]