mIRC Home    About    Download    Register    News    Help

Print Thread
#146030 30/03/06 03:08 PM
Joined: Jan 2003
Posts: 62
Attila Offline OP
Babel fish
OP Offline
Babel fish
Joined: Jan 2003
Posts: 62
Hi guys
I think i've found 2 bugs in the /sockread command with &binvar:
if you try to sockread -n &binvar
it supposed to read all lines separated by $crlf
okay but sometimes, there are no $crlf and you can see the on *:sockread event is calling but $sockbr is always $null.After, never appends, you can type /socklist, the socket is still open (maybe it's false, and mirc lie to me xD)
I've been waiting one day long and the socket is still open. i've changed the code by adding a "sockwrite -n &a" after the while ($sockbr) and i've received the remaining datas one day after the website send it to me!!!
here the code:

Code:
  
alias testbug {
  sockclose tb
  sockopen tb tvunderground.org.ru 80
}
on *:sockopen:tb:{
  sockwrite -n $sockname GET /index.php HTTP/1.0
  sockwrite -n $sockname $crlf
}
on *:sockread:tb:{
  if $sockerr { echo -s planté | return }
  sockread -n &a
  while $sockbr {
    echo -s < on a lu $bvar(&a,1,100).text
    sockread -n &a
  }
}



one other bug i've found (i think it's a bug)
in the help file, i can see "The -n switch allows you to read a $crlf terminated line into a &binvar. If the incoming line does not contain a $crlf, no bytes will be read into &binvar, unless you specify the -f switch, which forces the read (same as when reading into %vars)."

so it mean that if i write sockread -nf &binvar it supposed to parse datas as sockread %var does?
yeah, it's just supposed, because it send more than one line in the same time:
sockread -nf &binvar is exactly the same thing as sockread &binvar


note: i'm using mirc 6.17 and windows XP sp2

#146031 30/03/06 06:58 PM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Quote:
Hi guys
I think i've found 2 bugs in the /sockread command with &binvar:
if you try to sockread -n &binvar
it supposed to read all lines separated by $crlf
okay but sometimes, there are no $crlf and you can see the on *:sockread event is calling but $sockbr is always $null.

The real problem is that the receive-buffer of the socket (4 kilobytes apparently) is full, and there's no newline character in the buffer. Although strictly speaking, mIRC is acting correctly, this situation can indeed be undesirable. A workaround would be to use:

Code:
sockread -n &binvar
if ($sockbr == 0) && ($sock($sockname).rq >= 4096) sockread -nf &binvar

instead of just "sockread -n &binvar".


Quote:
one other bug i've found (i think it's a bug) [..] so it mean that if i write sockread -nf &binvar it supposed to parse datas as sockread %var does? yeah, it's just supposed, because it send more than one line in the same time: sockread -nf &binvar is exactly the same thing as sockread &binvar

Confirmed, that is a bug. /sockread -nf &binvar should not read more than one line at once, but it does.


Saturn, QuakeNet staff
#146032 31/03/06 04:24 PM
Joined: Jan 2003
Posts: 62
Attila Offline OP
Babel fish
OP Offline
Babel fish
Joined: Jan 2003
Posts: 62
thanx for your code, but i can't use sockread -nf is the command is buggy

someone knows when the bug will be corrected if i had to change my code or if i wait for a new version

#146033 31/03/06 04:30 PM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
You actually can use /sockread -nf in that case, buggy or not, because there is guaranteedly no newline in the buffer when you use it in this case.


Saturn, QuakeNet staff
#146034 09/04/06 08:20 PM
Joined: Jan 2003
Posts: 62
Attila Offline OP
Babel fish
OP Offline
Babel fish
Joined: Jan 2003
Posts: 62
i hope khaled will correct this bug soon
thanx


Link Copied to Clipboard