Originally Posted By: MegaZeroX
Hi there fellas, it's been awhile for me! I have and this is actually the second time I've run into this issue, a /sockread obstacle where a script can't read the full page. So as an example I'm going to test this on drudgereport.com and we'll see what happens.

Code:
alias testgo.open {
  sockopen testgo drudgereport.com 80
}
on 1:sockopen:testgo:{
  var %a = .sockwrite -n testgo 
  %a GET / HTTP/1.0
  %a Accept: */*
  %a Referer: http://www.drudgereport.com/
  %a Accept-Language: en-us
  %a UA-CPU: x86
  %a Accept-Encoding: No Compression
  %a Connection: Keep-Alive
  %a Host: drudgereport.com
  %a $crlf
}
on 1:sockread:testgo:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) { 
    sockclose testgo
    echo $chr(160)
    return 
  }
  if (%temp == $null) %temp = -
  echo 4 %temp
  goto nextread
}


You'll note that this last sockread code is pretty much straight out of the mIRC faq guide, even the goto is the same.

So we can run this with /testgo.open. We get a number of lines of html back correctly, but we don't get the whole page. It tends to stop around the first story headline. Any pointers would be greatly appreciated.


To start you have to much code in your sockread call here is a revised version to dump the full HTML

Code:
on 1:sockread:testgo:{
  if ($sockerr > 0) return
  var %temp | sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  echo -a %temp
}


if you want anything fancy in the read let me know, but I did what you asked :P I so hate goto's even in the LOOP instructions I rather use while loops if im gonna loop through. :P

Enjoy! cheers.

P.s> i forgot to mention that the sockclose testgo in your sockbr == 0 statement is not needed a simple return was sufficient I don't see any reason why you should call a socket close immediately, but it's entirely your choice I removed it out of the revised code I like to make things the smallest I can.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }