I am converting some perl code using LWP::UserAgent::DNS::Hosts to php.
What the perl code is doing is making page load time measurements against multiple individual servers in a load balancing pool. Since the servers are using name based virtual hosting, the perl code uses this line to change the url/hostname to ip binding:
LWP::UserAgent::DNS::Hosts->register_host(
'www.mytesturl.com' => '22.22.22.22',
);
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
#actually enforces new DNS settings as if they were in /etc/hosts
LWP::UserAgent::DNS::Hosts->enable_override;
$Timerstart=[gettimeofday];
my $response= $ua->get('http://www.mytesturl.com');
$TimeElapsed = tv_interval ($Timerstart,[gettimeofday]);
if ($response->is_success) {
print "<br>Response detected - Time to Load: $TimeElapsed seconds\r\n"
}
I know I can do this with raw socket manipulation, but I was hoping I could do it with cURL or another class library in PHP. The perl code actually repeats this inside a loop with several different IP's for the same url (each ip is a specific server) to test the servers individually.
Thanks-
I use it this way:
curl_setopt($ch, CURLOPT_INTERFACE,'eth0');
or you can also use an IP:
curl_setopt($ch, CURLOPT_INTERFACE,'85.128.174.26');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.