Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending muliple transactions over a single connection with cURL?

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
I'm using cURL to post data to a server, I retrieve the result of the post using CURLOPT_RETURNTRANSFER. Part of my project requires that I POST quite a large number of transactions to the same server using cURL. Is there a way I can send all the transactions across the same server connection and still retrieve the result, rather than having to open a new transaction each time?

Opening a connection can be quite time consuming and I'm concerned that if this has to be done a lot on one page it could result in page timeouts.
 
Heh.
I was kind of hoping something like the following would be possible:

Code:
curl_setopt($ch, CURLOPT_URL,&quot;<server to post to>&quot;);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);


foreach(item to post)
	{
	curl_setopt($ch, CURLOPT_POSTFIELDS, &quot;<data to post>&quot;);
	$resultxml=curl_exec($ch);
	$lastcurlerror=curl_error($ch);
	
	//process the result
	}
curl_close($ch);
 
I posted the same question on the php/cURL mailing list and recieved a few replies:


libcurl itself supports this kind of operation, but AFAIK the PHP/CURL binding
code does not. People have reported both success and failures after having
tried that stunt.

I hope that one day someone will make sure that the binding supports this.
---------------
I made this work with PHP 4.2 (I think) running with Apache on an NT box, but
I couldn't make it work on PHP4.3x on FreeBSD. ????!!!!
---------------

so it looks like it works for some people and not for others. I guess the only way I'll find out is to try it myself, but it doesn't seem to realiable. Ah well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top