From fa9c19811c353088688ba7de8a903bb62df05469 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sun, 29 Jul 2001 19:14:15 +0000 Subject: [PATCH] Changed from function to single body of code. --- exec/examples/socktest.js | 60 ++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/exec/examples/socktest.js b/exec/examples/socktest.js index 8d92bab8fe..8b2a8c85f2 100644 --- a/exec/examples/socktest.js +++ b/exec/examples/socktest.js @@ -1,45 +1,41 @@ load("sbbsdefs.js"); // CON_RAW_IN -function test() -{ - var socket = new Socket(); +console.status |= CON_RAW_IN; // Enable RAW input mode (pass-through ctrl chars) +var socket = new Socket(); - socket.debug=true; +socket.debug=true; - if(!socket.bind()) { - printf("!bind error %d\r\n",socket.last_error); - exit(); - } +if(!socket.bind()) { + printf("!bind error %d\r\n",socket.last_error); + exit(); +} - var addr=prompt("address"); - var port=Number(prompt("port")); +var addr=prompt("address"); +var port=Number(prompt("port")); - if(!socket.connect(addr,port)) { - printf("!connect error %d\r\n",socket.last_error); - exit(); - } +if(!socket.connect(addr,port)) { + printf("!connect error %d\r\n",socket.last_error); + exit(); +} + +printf("\r\nConnected to %s:%d - Ctrl-] to abort\r\n",addr,port); +console.pause(); - printf("\r\nConnected to %s:%d - Ctrl-] to abort\r\n",addr,port); - console.pause(); - - while(socket.is_connected && client.socket.is_connected) { - if(socket.data_waiting) { - buf = socket.read(); - client.socket.write(buf); - continue; - } - if((input=console.inkey())!="") { - if(input=="\x1d") /* Ctrl-] */ - break; - socket.write(input); - continue; - } - sleep(1); +while(socket.is_connected && client.socket.is_connected) { + if(socket.data_waiting) { + buf = socket.read(); + client.socket.write(buf); + continue; } + if((input=console.inkey())!="") { + if(input=="\x1d") /* Ctrl-] */ + break; + socket.write(input); + continue; + } + sleep(1); } -console.status |= CON_RAW_IN; // Enable RAW input mode (pass-through ctrl chars) -test(); console.status &= ~CON_RAW_IN; // Disable raw input mode print("\r\nEnd of socktest!\r\n"); \ No newline at end of file -- GitLab