mIRC Homepage
It's been awhile since I've done any scripting. I'm trying to use sockets to connect to a page that only has an IP address on it and then connect to the IRC server with that address. The problem is that the socket is returning more than the IP address, even though there is no HTML on the page. Here is what I'm getting:

Quote:
HTTP/1.1 200 OK
Date: Mon, 30 Aug 2010 20:30:19 GMT
Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Sun, 22 Aug 2010 19:05:49 GMT
ETag: "38c8182-e-48e6e384d9d40"
Accept-Ranges: bytes
Content-Length: 14
Content-Type: text/plain


I think the fact that I'm not getting more is a looping problem in the script.
You can use an IF to check if the line is the right line so you can use just that IP. You first have to look at your script and get it to read the entire page, however.

What version mirc are you running? I was messing with sockets and the code wouldnt bring in the data on 6.2, but I got 7.1 and it works fine.

Originally Posted By: bwr30060
It's been awhile since I've done any scripting. I'm trying to use sockets to connect to a page that only has an IP address on it and then connect to the IRC server with that address. The problem is that the socket is returning more than the IP address, even though there is no HTML on the page. Here is what I'm getting:

Quote:
HTTP/1.1 200 OK
Date: Mon, 30 Aug 2010 20:30:19 GMT
Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Sun, 22 Aug 2010 19:05:49 GMT
ETag: "38c8182-e-48e6e384d9d40"
Accept-Ranges: bytes
Content-Length: 14
Content-Type: text/plain


I think the fact that I'm not getting more is a looping problem in the script.


These are the page headers sent to the socket by the server. You need to parse the data accordingly to make sure you get the data you want from the page.
You should request HTTP/1.0 data instead of HTTP/1.1 .

The web server will return some unknown number of headers, like the ones you listed. It will then send a blank line. Then the content of the webpage will begin to send. You can make your script ignore everything it sees before that first blank line, and read everything after the blank line.

Put this right before your /sockopen command:

set %ignore 1


Then in your sockread event, add this check at the top:

var %read
sockread %read
if (%read == $null) { set %ignore 0 | return }
if (%ignore) return

;Rest of your code here. Data is in %read


If you plan on opening this socket more than once at a time, you will need to make the %ignore variable dynamic based on the socket name.

-genius_at_work
© mIRC Discussion Forums