mIRC Home    About    Download    Register    News    Help

Print Thread
#161323 05/10/06 10:50 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
anyone got a socket example on how to read the text from: for e.g http://www.mirc.co.uk/whatsnew.txt

?

#161324 06/10/06 04:34 AM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Code:
alias readmirc { sockclose readmirc | sockopen readmirc www.mirc.co.uk 80 }
on *:sockopen:readmirc:{
  sockwrite -n $sockname GET /whatsnew.txt HTTP/1.1
  sockwrite -n $sockname Host: www.mirc.co.uk $str($crlf,2)
}
on *:sockread:readmirc:{
  if ($sockerr > 0) { return }
  :C
  SockRead %temp3
  if ($sockbr == 0) { return }
  echo -a %temp3 
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#161325 06/10/06 05:39 AM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
If this is for a version check, you can use the Last-Modified header to reduce traffic. Then you only receive the header unless the file has been changed since a nominated time.
Code:
alias whatsnew if !$sock(whatsnew) { sockopen whatsnew www.mirc.co.uk 80 }
on *:sockopen:whatsnew:{
  if $sockerr { echo -aecti info * Sock error $+([,$sockname,]:)  $sock($sockname).wserr - $sock($sockname).wsmsg | return }
  sockwrite -n $sockname GET /whatsnew.txt? HTTP/1.1
  [color:blue]if $read(Whatsnew.txt,sn,Last-Modified:) { sockwrite -n $sockname If-Modified-Since: $v1 }[/color]
  sockwrite -n $sockname Host: www.mirc.co.uk $+ $str($crlf,2)
}
on *:sockread:whatsnew:{
  if !$sock($sockname).mark {
    var %a | sockread -f %a
    if *Last-Modified:* iswm %a { set -e %Last-Modified:whatsnew.txt $gettok(%a,2-,32) }
    if !%a { sockmark $sockname 1 }
  }
  else {
    sockread -fn &a
    breplace &a 0 10
    bwrite wn.tmp -1 -1 &a
  }
}
on *:sockclose:whatsnew:{
  if $isfile(wn.tmp) {
    [color:gray]; if you did download the file, display it[/color]
    .remove whatsnew.txt | .rename wn.tmp Whatsnew.txt
    window -n @Whats_new | loadbuf -pirc $+ $colour(listbox text) @Whats_new Whatsnew.txt
    sline @Whats_new 4 | window -g1 @Whats_new | beep 5
    [color:green]if %Last-Modified:whatsnew.txt { write -il1 Whatsnew.txt Last-Modified: $v1 $str($lf,2) }[/color]
    [color:gray]; write file modified time to the file for future checks[/color]
  }
  else { echo -aicet info * (Whatsnew.txt) Nothing new there, move along! }
}

#161326 06/10/06 01:09 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks alot guys. im dont know why but neither work for me

:S

im on mirc 6.2 by the way!

Last edited by pouncer; 06/10/06 02:56 PM.
#161327 06/10/06 08:19 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
on mine type /readmirc


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#161328 06/10/06 08:34 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
i did, nothng happens

#161329 06/10/06 09:47 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Maybe your firewall is blocking mIRC from connecting on port 80..

#161330 07/10/06 12:37 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
maybe its my router :s


Link Copied to Clipboard