I can reproduce this and I agree $sockerr shouldn't be set there, winsock reports that 10101 is a graceful shutdown in progress.
If you can read all the data in your on sockread event using the loop on $sockbr, if you read all the receive buffer using /sockread $sock($sockname).rq &a, mIRC will call on sockclose with $sockerr set to 3 before you can read everything inside on sockread, you are forced to use on sockclose to read everything.
The best for scripters would really be to have mIRC stops triggering on sockclose in this situation but rather triggers it later, when the socket is actually closed.
Handling this situation in a script is not hard but having it built in would make our life easier and would improve the design.

Code:
;/testsock
alias testsock {
  if (!$sslready) { echo -s * /testsock requires SSL | return }
  sockclose testsock
  if ($exists(testsock.txt)) .remove testsock.txt
  sockopen -e testsock dl.dropboxusercontent.com 443
}
on *:sockopen:testsock:{
  if ($sockerr) { echo -s * /testsock sockerr on sockopen $sock($sockname).wserr $sock($sockname).wsmsg | return }
  sockwrite -n $sockname GET /u/4249275/Bomberman/bomber.mrc HTTP/1.1
  sockwrite -n $sockname Host: dl.dropboxusercontent.com
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname 
  sockmark $sockname $false
}
on *:sockread:testsock:{
  if (!$sockerr) {
    if ($sock($sockname).mark) {
      echo -a reading $sock($sockname).rq bytes
      sockread $sock($sockname).rq &a
    }
    else {
      var %a
      sockread %a
      if (%a == $null) sockmark $sockname 1
      elseif ($sock($sockname).mark == $false) {
        if (*200 OK* !iswm %a) {
          echo -s * /testsock cannot find the file on the server
          sockclose testsock
        }
        sockmark $sockname 0
      }
    }
  }
  else {
    echo -s * /testsock sockerr on sockread $sock($sockname).wserr $sock($sockname).wsmsg
  }
}

on *:sockclose:testsock:{
  if ($sockerr) { echo -s * /testsock sockerr on sockclose $sock($sockname).wserr $sock($sockname).wsmsg -- $!sock().rq = $sock($sockname).rq | return }
  echo -a sockclose $!sock().rq : $sock($sockname).rq
  if ($exists(testsock.txt)) .remove testsock.txt
}

Last edited by Wims; 07/08/14 05:19 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel