CURL not to wait for an answer?

There is a simple code:
$v1 = microtime(true);
$main = curl_init('http://site.com/test.php');
curl_setopt($main, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($main, CURLOPT_USERAGENT, 'Opera/9.80');
curl_setopt($main, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($main);

$v2 = microtime(true);
echo $v2 - $v1.'<br>';
echo 'ok';


On the landing page at http://site.com/test.php posted code:
sleep(3);
echo 'target';

The first script is always waiting for when the second will work and respond, i.e., its running time is not less than 3 seconds.
How do I send curl request and wait for response and immediately show OK in the first script?
June 7th 19 at 14:50
2 answers
June 7th 19 at 14:52
Solution
June 7th 19 at 14:54
Solution
https://gist.github.com/Xeoncross/2362936
Or as said SagePtr set CURLOPT_TIMEOUT_MS

Find more questions by tags PHP