i'm trying to write a php script that sends an http request to a
server, get some info. from that server, and print it to the screen.
unfortunately, this script takes longer to connect than i'd like.
replacing the server's ip address with 127.0.0.1 noticeably speeds
things up, but doesn't work if someone's on a virtual host (the paths
would be different).
here's the script i'm using:
<?
$fsock = fsockopen('tcp://ipaddress',80,$errno,$errstr,1);
fputs($fsock,"GET /filename.txt HTTP/1.0\r\n");
fputs($fsock,"Host: domain.com\r\n\r\n");
while (!feof($fsock))
echo fgets($fsock);
fclose($fsock);
?>
i'm aware that fopen would work in this particular case, but in the
context of what i'm trying to do, it doesn't (i don't, ultimately, want
to get the contents - i just want to send an http request and be done
with it, for the purposes of initiating time consuming tasks such as
backups in safe mode, without requiring the user wait for the task to
complete).
any ideas as to how i could speed the above code up?
alternatively, any ideas how, when ipaddress is replaced with
127.0.0.1, the path on the domain that's being requested could be
adjusted to the real host (as opposed to the virtual one)?