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).

!752

p-substance {
  final JTextField tf1 = jTextField("localhost");
  final JTextField tf2 = jTextField("4999");
  showForm(
    "Host", tf1,
    "Port", tf2, r-thread {
      connect(getTextTrim(tf1), parseInt(getTextTrim(tf2)));
    });
}

svoid connect(S host, int port) {
  print("Connecting to " + host + ":" + port + "...");
  final DialogIO io = talkTo(host, port);
    
  // output
  thread {
    S line;
    while ((line = readLine()) != null)
      io.sendLine(line);
  }
  
  // input
  while (io.isStillConnected()) {
    if (io.waitForLine()) {
      S line = io.readLineNoBlock();
      print("> " + line);
    }
  }
  
  print();
  print("[logout]");
}

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: 436 / 517
Referenced in: