Subj : Is there a bug in Socket.data_waiting ?
To : nelgin
From : Digital Man
Date : Wed Feb 21 2024 11:51 pm
Re: Is there a bug in Socket.data_waiting ?
By: nelgin to Digital man on Wed Feb 21 2024 11:30 am
> I'm trying to fetch the login screen for a MUD and having some issues.
>
> If I use telnet aardmud.org 4000 then it connects and.
> nc aardmud.org 4000 produces some junk characters and then displays the
> login screen. I guess they're some sort of terminal detection or
> negotiation. tcpdump output doesn't look like telnet negotiation.
>
> Now with js I'm trying this:
>
> var sock = new Socket(SOCK_STREAM);
> try { sock.connect('aardmud.org',4000,5) }
> catch(e) {
> writeln(e);
> exit();
> }
> sock.is_connected show true. So let me check if there's some data waiting
> for me.
>
> sock.data_waiting shows false
> sock.ndata shows 0
You're not going to have data waiting to read *immediately* after a connect.
> sock.poll(0,true) shows the socket is set for reading.
>
> 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?
Socket.recvline() waits for data (an entire "line" of it, in fact). That's why it has a timeout parameter (that defaults to 30 seconds).
--
digital man (rob)
Synchronet/BBS Terminology Definition #19:
DCD = Data Carrier Detect
Norco, CA WX: 50.7�F, 91.0% humidity, 0 mph E wind, 0.16 inches rain/24hrs
---
� Synchronet � Vertrauen � Home of Synchronet � [vert/cvs/bbs].synchro.net