php - POST variables without waiting for the execution of the end side script -
i have situation...
i'm posting variables using curl remote host. below can see how php scripts, like:
local php script:
$url = 'http://somesite.com/something.php'; data = array ('key1' => 'string1', 'key2' => 'string2', 'key3' => 'string3'); $ch = curl_init(); curl_setopt ($ch, curlopt_url, $url); curl_setopt ($ch, curlopt_post, 1); curl_setopt ($ch, curlopt_postfields, $data); curl_exec ($ch); curl_close ($ch); // code other stuff.
remote php script:
$string1 = $_post['key1']; // if string exists in big folder of text files. sleep(30); // file contain string.
my problem local php script loading until remote script finish execution. question is, there way post variables remote host , continue script execution ? not mandatory using curl, php solution. thanks!
add timeout code:
curl_setopt($ch, curlopt_timeout, 1);
this continue execute rest part of code after 1 second.
curlopt_timeout maximum number of seconds allow curl functions execute.
or can use miliseconds:
curlopt_timeout_ms maximum number of milliseconds allow curl functions execute. if libcurl built use standard system name resolver, portion of connect still use full-second resolution timeouts minimum timeout allowed of 1 second.
you can read further explanation here.
once other script start continue without have waiting finish output.
Comments
Post a Comment