tags:

views:

437

answers:

2

In PHP (v5), is there a way to make multiple requests on an open curl connection?

I'm noticing that my big bottleneck is the timeout/teardown of the connection its self (i'm making lots of small data requests that finish quickly), so I would like to be able to do something like open

init curl connection,

set url/params, do request, get results set url/params, do request, get results

close curl

I just dont know if this is possible at all.

+1  A: 

Probably the curl_multi_* functions are what you are looking for.

phihag
A: 

You should be able to do this by adding Keep-alive headers:

$headers  = array
(
    "Keep-alive: 300",
    "Connection: keep-alive",
    // ... other headers...
);

curl_setopt($this->curl_handle, CURLOPT_HTTPHEADER, $headers);
Greg