<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to use curl_multi() without blocking</title>
	<atom:link href="http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/</link>
	<description>a blog about building stuff on the web</description>
	<lastBuildDate>Wed, 11 Aug 2010 16:25:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: floesen</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-1108</link>
		<dc:creator>floesen</dc:creator>
		<pubDate>Fri, 09 Jul 2010 12:41:13 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-1108</guid>
		<description>Indeed. It&#039;s a beutiful piece of code! 
This post, together with your post on &lt;a href=&quot;http://www.askapache.com/php/curl-multi-downloads.html&quot; rel=&quot;nofollow&quot;&gt;http://www.askapache.com/php/curl-multi-downloads...&lt;/a&gt; just made me understand how tu use multihandles in useful way! </description>
		<content:encoded><![CDATA[<p>Indeed. It&#039;s a beutiful piece of code!<br />
This post, together with your post on <a href="http://www.askapache.com/php/curl-multi-downloads.html" rel="nofollow"></a><a href="http://www.askapache.com/php/curl-multi-downloads.." rel="nofollow">http://www.askapache.com/php/curl-multi-downloads..</a>. just made me understand how tu use multihandles in useful way!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Korail</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-1033</link>
		<dc:creator>Korail</dc:creator>
		<pubDate>Mon, 28 Jun 2010 19:33:48 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-1033</guid>
		<description>Firstly, apologies if this is a bit of a noob question but can anyone give any tips on how to get proper responses from the following site using RollingCurl? Is it to do with cookies? I am not a programmer by any stretch of the imagination so could do with some pointers. 
 
The URL is &quot;http://logis.korail.go.kr/getcarinfo.do?car_no=&quot;  with a number appended to it, ranging from 8201 through 8286. The first time you enter the URL into your browser you get a login screen back. If you refresh, or enter a URL with a different number appended, you get one of two different responses. The first response has two input boxes, one of which is populated with the number you appended to the URL, the second being empty. The second response is the same as the first with the addition of two tables, with various data fields, underneath the two input boxes. 
 
When you use the code below the html received back is for the login page in every instance. How do I implement RollingCurl so I get on of the other two repsonses back? 
 
&lt;?php 
 
// PROCESS RESPONSE 
function request_callback($response, $info) { 
        echo($response); 
echo &quot;&lt;hr&gt;&quot;; 
} 
 
 
// REQUIRE ROLLING CURL 
require(&quot;RollingCurl.php&quot;); 
 
 
// POPULATE LOCO ARRAY 
$class = 8201; 
$class_size = 5; //RESTRICTED TO 5 FOR TESTING PURPOSES, SHOULD BE 86! 
for ($i=0;$i&lt;$class_size;$i++){ 
$loco[]=$class+$i; 
} 
 
 
// POPULATE URL ARRAY 
$url = &#039;http://logis.korail.go.kr/getcarinfo.do?car_no=&#039;; 
for ($i=0;$i&lt;sizeof($loco);$i++){ 
$urls[]=$url.$loco[$i]; 
} 
 
 
// FETCH URLS 
$rc = new RollingCurl(&quot;request_callback&quot;); 
$rc-&gt;window_size = $class_size; 
foreach ($urls as $url) { 
    $request = new Request($url); 
    $rc-&gt;add($request); 
} 
$rc-&gt;execute(); 
 
?&gt; 
 
 
 </description>
		<content:encoded><![CDATA[<p>Firstly, apologies if this is a bit of a noob question but can anyone give any tips on how to get proper responses from the following site using RollingCurl? Is it to do with cookies? I am not a programmer by any stretch of the imagination so could do with some pointers. </p>
<p>The URL is &quot;http://logis.korail.go.kr/getcarinfo.do?car_no=&quot;  with a number appended to it, ranging from 8201 through 8286. The first time you enter the URL into your browser you get a login screen back. If you refresh, or enter a URL with a different number appended, you get one of two different responses. The first response has two input boxes, one of which is populated with the number you appended to the URL, the second being empty. The second response is the same as the first with the addition of two tables, with various data fields, underneath the two input boxes. </p>
<p>When you use the code below the html received back is for the login page in every instance. How do I implement RollingCurl so I get on of the other two repsonses back? </p>
<p>&lt;?php </p>
<p>// PROCESS RESPONSE<br />
function request_callback($response, $info) {<br />
        echo($response);<br />
echo &quot;&lt;hr&gt;&quot;;<br />
} </p>
<p>// REQUIRE ROLLING CURL<br />
require(&quot;RollingCurl.php&quot;); </p>
<p>// POPULATE LOCO ARRAY<br />
$class = 8201;<br />
$class_size = 5; //RESTRICTED TO 5 FOR TESTING PURPOSES, SHOULD BE 86!<br />
for ($i=0;$i&lt;$class_size;$i++){<br />
$loco[]=$class+$i;<br />
} </p>
<p>// POPULATE URL ARRAY<br />
$url = &#039;http://logis.korail.go.kr/getcarinfo.do?car_no=&#039;;<br />
for ($i=0;$i&lt;sizeof($loco);$i++){<br />
$urls[]=$url.$loco[$i];<br />
} </p>
<p>// FETCH URLS<br />
$rc = new RollingCurl(&quot;request_callback&quot;);<br />
$rc-&gt;window_size = $class_size;<br />
foreach ($urls as $url) {<br />
    $request = new Request($url);<br />
    $rc-&gt;add($request);<br />
}<br />
$rc-&gt;execute(); </p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Smith</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-952</link>
		<dc:creator>Nick Smith</dc:creator>
		<pubDate>Fri, 28 May 2010 08:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-952</guid>
		<description>Excellent code, thanks :) Just to let others who might be struggling to get it to work, curl_multi_info_read() doesn&#039;t work in PHP versions before 5.2.0, and returns NULL immediately. </description>
		<content:encoded><![CDATA[<p>Excellent code, thanks <img src='http://www.onlineaspect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Just to let others who might be struggling to get it to work, curl_multi_info_read() doesn&#39;t work in PHP versions before 5.2.0, and returns NULL immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tojochacko</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-922</link>
		<dc:creator>tojochacko</dc:creator>
		<pubDate>Tue, 11 May 2010 12:55:53 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-922</guid>
		<description>try the second parameter in the callback function. Its an array and you may be able to reference the response to the request using the url key. </description>
		<content:encoded><![CDATA[<p>try the second parameter in the callback function. Its an array and you may be able to reference the response to the request using the url key.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subodh</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-902</link>
		<dc:creator>Subodh</dc:creator>
		<pubDate>Wed, 07 Apr 2010 15:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-902</guid>
		<description>This is the callback that is called. Is the callback synchronous i.e, because when one of the handle is done it calls this function. The output is zip so I write it to a zip file locally. If successful I unzip it. 
This writing to file and unziping takes time and after it gets completed only then the download of next items resume 
 
In my case 
I am downloading 3 files in batch 
if 1st file is downloaded successfully it will call the callback 
after the writing to zip and unzipping is finished 
I have got this error 
 
* Connection #2 to host xxxxx left intact 
 92  138M   92  127M    0     0  23996      0  1:40:41  1:32:50  0:07:51   129 
 99  129M   99  128M    0     0  24250      0  1:33:16  1:32:50  0:00:26   327* Connection #2 seems to be dead! 
* Closing connection #2 
* About to connect() to xxxxx port xx (#2) 
*   Trying X.X.X.X...  
 92  138M   92  127M    0     0  23665      0  1:42:06  1:34:09  0:07:57   126 
 99  129M   99  128M    0     0  23916      0  1:34:34  1:34:09  0:00:25   275* Connected to XXXX (X.X.X.X) port X (#2) 
&gt; GET XXXX/daily.zip HTTP/1.1 
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) 
Host: XXXXX 
Accept: */* </description>
		<content:encoded><![CDATA[<p>This is the callback that is called. Is the callback synchronous i.e, because when one of the handle is done it calls this function. The output is zip so I write it to a zip file locally. If successful I unzip it.<br />
This writing to file and unziping takes time and after it gets completed only then the download of next items resume </p>
<p>In my case<br />
I am downloading 3 files in batch<br />
if 1st file is downloaded successfully it will call the callback<br />
after the writing to zip and unzipping is finished<br />
I have got this error </p>
<p>* Connection #2 to host xxxxx left intact<br />
 92  138M   92  127M    0     0  23996      0  1:40:41  1:32:50  0:07:51   129<br />
 99  129M   99  128M    0     0  24250      0  1:33:16  1:32:50  0:00:26   327* Connection #2 seems to be dead!<br />
* Closing connection #2<br />
* About to connect() to xxxxx port xx (#2)<br />
*   Trying X.X.X.X&#8230;<br />
 92  138M   92  127M    0     0  23665      0  1:42:06  1:34:09  0:07:57   126<br />
 99  129M   99  128M    0     0  23916      0  1:34:34  1:34:09  0:00:25   275* Connected to XXXX (X.X.X.X) port X (#2)<br />
&gt; GET XXXX/daily.zip HTTP/1.1<br />
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)<br />
Host: XXXXX<br />
Accept: */*</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subodh</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-898</link>
		<dc:creator>Subodh</dc:creator>
		<pubDate>Wed, 07 Apr 2010 14:54:23 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-898</guid>
		<description>Hi I am using ur code for one of my projects where I have a set of files to download which I do simultaneously. 
I hit a problem in the callback 
 
function requestCallback($response, $info, $urls_array = null) { 
$filelocation = getFileLocation($urls_array, $info[&#039;url&#039;]); 
if (isset($filelocation)){ 
if (file_put_contents($filelocation.&quot;.zip&quot;, $response)) { 
$zip = new ZipArchive(); 
if ($zip-&gt;open($filelocation.&quot;.zip&quot;) === TRUE) { 
echo &quot;n unzipping &quot;.$filelocation.&quot;.zip n&quot;; 
makeDirectory($filelocation); 
$zip-&gt;extractTo($filelocation); 
echo &quot;Completed unzipping &quot;.$filelocation.&quot;.zip n&quot;; 
} else { 
logErrorMail(&quot;Archive &quot;.$filelocation.&quot;.zip is invalid or corrupt&quot;); 
} 
$zip-&gt;close(); 
} else { 
logErrorMail(&quot;Error: unable to write to zip file&quot;); 
} 
} else { 
logErrorMail(&quot;Error: Cannot find file location&quot;); 
} 
} </description>
		<content:encoded><![CDATA[<p>Hi I am using ur code for one of my projects where I have a set of files to download which I do simultaneously.<br />
I hit a problem in the callback </p>
<p>function requestCallback($response, $info, $urls_array = null) {<br />
$filelocation = getFileLocation($urls_array, $info[&#039;url&#039;]);<br />
if (isset($filelocation)){<br />
if (file_put_contents($filelocation.&quot;.zip&quot;, $response)) {<br />
$zip = new ZipArchive();<br />
if ($zip-&gt;open($filelocation.&quot;.zip&quot;) === TRUE) {<br />
echo &quot;n unzipping &quot;.$filelocation.&quot;.zip n&quot;;<br />
makeDirectory($filelocation);<br />
$zip-&gt;extractTo($filelocation);<br />
echo &quot;Completed unzipping &quot;.$filelocation.&quot;.zip n&quot;;<br />
} else {<br />
logErrorMail(&quot;Archive &quot;.$filelocation.&quot;.zip is invalid or corrupt&quot;);<br />
}<br />
$zip-&gt;close();<br />
} else {<br />
logErrorMail(&quot;Error: unable to write to zip file&quot;);<br />
}<br />
} else {<br />
logErrorMail(&quot;Error: Cannot find file location&quot;);<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Eduardo</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-895</link>
		<dc:creator>Alberto Eduardo</dc:creator>
		<pubDate>Wed, 31 Mar 2010 15:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-895</guid>
		<description>Im trying to access the cookies from the callback function is it possible? I check my cookie and this one is still empty when I try to access it from the callback function 
 
Thanks a lot </description>
		<content:encoded><![CDATA[<p>Im trying to access the cookies from the callback function is it possible? I check my cookie and this one is still empty when I try to access it from the callback function </p>
<p>Thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Eduardo</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-896</link>
		<dc:creator>Alberto Eduardo</dc:creator>
		<pubDate>Wed, 31 Mar 2010 15:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-896</guid>
		<description>Im trying to access the cookies from the callback function is it possible? I check my cookie and this one is still empty when I try to access it from the callback function 
 
Thanks a lot </description>
		<content:encoded><![CDATA[<p>Im trying to access the cookies from the callback function is it possible? I check my cookie and this one is still empty when I try to access it from the callback function </p>
<p>Thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-893</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Fri, 26 Mar 2010 07:28:33 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-893</guid>
		<description>trying to implement this, still no luck ;( </description>
		<content:encoded><![CDATA[<p>trying to implement this, still no luck ;(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Priit</title>
		<link>http://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/comment-page-1/#comment-888</link>
		<dc:creator>Priit</dc:creator>
		<pubDate>Thu, 11 Mar 2010 20:58:25 +0000</pubDate>
		<guid isPermaLink="false">http://onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/#comment-888</guid>
		<description>If you process the errors in else {} part, you will see that up to 5 requests will return errors with code value 0 ($info[&#039;http_code&#039;] == 0). You much check if you have already sent all the urls (in $urls) as requests before making another one (if (sizeof($urls) &gt; $i +1){create new request}) </description>
		<content:encoded><![CDATA[<p>If you process the errors in else {} part, you will see that up to 5 requests will return errors with code value 0 ($info[&#39;http_code&#39;] == 0). You much check if you have already sent all the urls (in $urls) as requests before making another one (if (sizeof($urls) &gt; $i +1){create new request})</p>
]]></content:encoded>
	</item>
</channel>
</rss>
