Subj : Is there a bug in Socket.data_waiting ? To : nelgin From : Digital Man Date : Wed Feb 21 2024 08:24 pm Re: Is there a bug in Socket.data_waiting ? By: nelgin to Digital Man on Wed Feb 21 2024 01:52 pm > Re: Is there a bug in Socket.data_waiting ? > By: Digital Man to nelgin on Wed Feb 21 2024 11:25:52 > > > > now if I use sock.recvline I get a line of data. So if there's data > > > waiting, why wouldn't data_waiting tell me? > > > I would expect data_waiting to be true. > > Definately false. > $ cat socktest.js > > 'use strict'; > load("sbbsdefs.js"); > load('sockdefs.js'); > > > var sock = new Socket(SOCK_STREAM); > try { sock.connect('aardmud.org',4000,5) } > catch(e) { > writeln(e); > exit(); > } Socket.connect() doesn't throw an exception upon failure (it just retuns false on failure) - so why the try/catch here? > writeln("data? " + sock.data_waiting); > sock.close(); > bbs@bbs:/sbbs/xtrn/mudlist/scripts$ jsexec -n socktest.js > data? false I wrote a quick little test here and it shows Socket.data_waiting working as expected: var sock = new Socket(); if(!sock.connect("vert.synchro.net", 23)) { alert("connect failure " + sock.error_str); exit(1); } while(sock.is_connected) { if(sock.data_waiting) print(JSON.stringify(sock, null, 4)); } -- digital man (rob) Sling Blade quote #10: Morris: I stand on the hill, not for thrill, but for the breath of a fresh kill Norco, CA WX: 53.7øF, 87.0% humidity, 1 mph NNW wind, 0.19 inches rain/24hrs .