socket question - 05/10/06 10:50 PM
anyone got a socket example on how to read the text from: for e.g http://www.mirc.co.uk/whatsnew.txt
?
?
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 }
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! } }