<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
I posted this on StackOverflow, but thought I'd check with folks here to see if they have any suggestions-<br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
<br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
I am converting some perl code using LWP::UserAgent::DNS::Hosts to php.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
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:</p>
<pre class="lang-php prettyprint prettyprinted" style="margin:0px 0px 10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;background-repeat:initial initial">
<code style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;background-repeat:initial initial"><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">    LWP</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175);background-repeat:initial initial">UserAgent</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">DNS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175);background-repeat:initial initial">Hosts</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">register_host</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
    </span><span class="str" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0);background-repeat:initial initial">'<a href="http://www.mytesturl.com">www.mytesturl.com</a>'</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">=></span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> </span><span class="str" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0);background-repeat:initial initial">'22.22.22.22'</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
    </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">

    </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139);background-repeat:initial initial">my</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> $ua </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> LWP</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175);background-repeat:initial initial">UserAgent</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139);background-repeat:initial initial">new</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
    $ua</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">timeout</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">(</span><span class="lit" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0);background-repeat:initial initial">10</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
    $ua</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">env_proxy</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">

    </span><span class="com" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:gray;background-repeat:initial initial">#actually enforces new DNS settings as if they were in /etc/hosts</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
    LWP</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175);background-repeat:initial initial">UserAgent</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">DNS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">::</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175);background-repeat:initial initial">Hosts</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">enable_override</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">

    $Timerstart</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">=[</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">gettimeofday</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">];</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">

    </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139);background-repeat:initial initial">my</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> $response</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> $ua</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139);background-repeat:initial initial">get</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">(</span><span class="str" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0);background-repeat:initial initial">'<a href="http://www.mytesturl.com">http://www.mytesturl.com</a>'</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">

    $TimeElapsed </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> tv_interval </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">$Timerstart</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">,[</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">gettimeofday</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">]);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">

    </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139);background-repeat:initial initial">if</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">$response</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">-></span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">is_success</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
       </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139);background-repeat:initial initial">print</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial"> </span><span class="str" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0);background-repeat:initial initial">"<br>Response detected - Time to Load: $TimeElapsed seconds\r\n"</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">
    </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);background-repeat:initial initial">}</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
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.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
Thanks-</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">
Joe<br></p>