cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Connections ??

From: David Colter <dolan2go_at_yahoo.com>
Date: Sat, 16 Feb 2008 10:19:24 -0500

Any comments on the question of 'opening connections' for several
pages from the same host?

To summarize what's below, the verbose output shows:

  Connection #0 to host www.aapilots.com left intact...
Connection #1 to host www.aapilots.com left intact....
Connection #2 to host www.aapilots.com left intact...
Connection #3 to host www.aapilots.com left intact...
Connection #4 to host www.aapilots.com left intact...
Closing connection #4.....
"Opens 6th connection"...
* Closing connection #0
* Closing connection #1
* Closing connection #2
* Closing connection #3

I have a single curl_init($ch1) and use 6 curl_exec($ch1) and one
curl_close($ch1).

Is this the most efficient way to use curl when my server won't do
redirections?

Thanks,
David

On Feb 8, 2008, at 9:19 PM, David Colter wrote:

> Please advise on the best practice for implementing curl/php when
> using several different page requests.
>
> The host is always the same, the script is capturing and managing
> cookie management and I am just changing the curlopt's that are
> different from the last setting. (my server doesn't allow redirects)
> I'm only
> using 'curl_init ()' once for 1 handle and using cur_exec for each
> new page requested. In the
> verbose output it is warning 'closing connection 4' and then at the
> end states 'closing connection 0' thru 'closing connection 4'.
>
> Is this normal for this type of process? Any suggestions would be
> greaty appreciated. Below is an example of the curl portion of the 1st
> page request I'm using. BTW, everything is working splendidly
> otherwise. Many thanks for the thoroughness of curl.
>
> $ch1 = curl_init();
>
> curl_setopt($ch1, CURLOPT_MAXCONNECTS, 6);
> curl_setopt($ch1, CURLOPT_USERAGENT, $WEBBOT_NAME);
> curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
> curl_setopt($ch1, CURLOPT_URL, $target);
> curl_setopt($ch1, CURLOPT_REFERER, $ref);
> curl_setopt($ch1, CURLOPT_VERBOSE, TRUE);
> curl_setopt($ch1, CURLOPT_STDERR, $fp);
> curl_setopt($ch1, CURLOPT_NOPROGRESS, FALSE);
> curl_setopt($ch1, CURLOPT_HTTPHEADER, $header_array);
> curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE);
> curl_setopt($ch1, CURLOPT_COOKIESESSION, TRUE);
> # curl_setopt($ch1, CURLOPT_COOKIEJAR, $cookie_file);
> # curl_setopt($ch1, CURLOPT_COOKIEFILE, $cookie_file);
> curl_setopt($ch1, CURLOPT_HEADER, TRUE);
> curl_setopt($ch1, CURLOPT_NOBODY, TRUE);
> curl_setopt($ch1, CURLOPT_POST, FALSE);
> curl_setopt($ch1, CURLOPT_FRESH_CONNECT, TRUE);
> # curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, TRUE);
>
> $page1_array_hdr['FILE'] = curl_exec($ch1);
> $page1_array_hdr['ERROR'] = curl_error($ch1);
> $page1_array_hdr['STATUS'] = curl_getinfo($ch1);
>
> Thanks,
> David Colter
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-02-16