mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2008
Posts: 2
G
gelupa Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
G
Joined: Jan 2008
Posts: 2
I'm making a script that downloads the indexpage of a website, parses it, and displays me the info I need. The problem is the website is on a webhotel, so it has a virtual host. Meaning, this particular webpage has the same IP-address than the webhotel itself.

Here's a copypaste from the mIRC Help:

"/sockopen [-de] [bindip] <name> <address> <port>

The /sockopen command initiates a connection to the specified address and port. You can specify either an ip address or a named address (which will be resolved to an ip address)."

Now if I understand this correctly, mIRC resolves the IP-address of the host and initiates the connection directly to that IP-address. Which like I wrote earlier is the same of the webhotel's. So when I try and download the indexpage I want, I end up getting that of the webhotel's frown

I realize this is a long shot, but is there any way to get mIRC to connect to a hostname instead of its' IP-address?

Last edited by gelupa; 08/01/08 10:29 PM.
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
At the socket level the hostname and the IP are the same, ie. mIRC resolves the hostname to the IP because that is the only valid thing it can do. What you need to do after the socket connects is to specify the 'Host' HTTP header, which is what the web server uses to determine which host you really want to connect to.

eg:
Code:
on *:SOCKOPEN:yoursocket: {
  sockwrite -n $sockname GET /somepage.html HTTP/1.1
  sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
  sockwrite -n $sockname Host: hostname.com
  sockwrite -n $sockname Connection: keep-alive
  sockwrite $sockname $crlf
}


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Jan 2008
Posts: 2
G
gelupa Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
G
Joined: Jan 2008
Posts: 2
This worked like a charm!

Thank you ever so much. I spent hours trying to get this to work. And I thought I knew something about the subject..

Best regards,
Jesse


Link Copied to Clipboard