I’m trying to open a socket on a host using the following code:
$timeout = 10;
$s = stream_socket_client('mywebsite.com:80', $errcode, $errstring, $timeout);
$message = "GET /index.php HTTP/1.0\r\n\r\n";
fwrite($s, $message);
while(!feof($s)){
echo fread($s, 1024);
}
Nothing fancy, just an example I found. The problem is that every time I run the code I get different files. I think this is because the host is a shared one.
Is there a way to overcome this problem, that is, pull reliably the proper file I’m trying to get?
Thank you.
in the HTTP request you have to specify which host you’re accessing. as you noted correctly multiple DNS entries can point to the same IP address.