mIRC Home    About    Download    Register    News    Help

Print Thread
socket help #172012 03/03/07 10:39 PM
Joined: Dec 2002
Posts: 79
F
Fantas Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: Dec 2002
Posts: 79
i'm trying to check if the file exists, problem is it says the 404 error message like 30 times. Sometimes it says 404 even tho 404 isn't in %temp. The %site and %url and %file are all right %site is like www.site.com %url is like /pics/pic.jpg %file would be pic.jpg so what am i doing wrong? the http:// the webpage put in not me



on *:SOCKOPEN:cnb: {
echo -s *** $sockname was just opened, Retrieving file %file
sockwrite -n $sockname GET / $+ %url HTTP/1.1
sockwrite -n $sockname Host: $+ %site
sockwrite -n $sockname Connection: Keep-Alive
sockwrite $sockname $crlf

}

on *:SOCKCLOSE:cnb: {
echo -s *** $sockname just closed
}

on *:SOCKREAD:cnb: {
sockread %temp
if (404 isin %temp) msg $chan %file not found
if (302 isin %temp) msg $chan %file has been moved
if (301 isin %temp) msg $chan %file moved permanently
}

Re: socket help [Re: Fantas] #172013 03/03/07 10:58 PM
Joined: May 2003
Posts: 41
D
Damsulegna Offline
Ameglian cow
Offline
Ameglian cow
D
Joined: May 2003
Posts: 41
Try it with simple domain name
sockwrite -n $sockname Host: site.com


try not to use Host: $+ %site as the $+ will make it Host:%Site surely

Also is %url prefixed with /
if so wouldnt GET / $+ %url return //pics/pic.jpg

just a few thoughts.


If At First You Don't Succeed, Ask Someone For Help......
Re: socket help [Re: Fantas] #172017 04/03/07 12:40 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
For debugging purposes, you could put an echo line to display the contents of %temp

[/code]
on *:SOCKREAD:cnb:{
var %temp
sockread %temp
echo -s > %temp
;...
}
[/code]

You will be able to see each line that is /sockread.

Also, if (404 isin %temp) will match on ANY instance of '404' within the page source.

For mIRC sockets, it's usually better to use HTTP/1.0 instead of HTTP/1.1

-genius_at_work

-genius_at_work