Hoe kan ik in PHP een cURL connectie open houden?
Tot nu toe heb ik het onderstaande script alleen lijkt het erop dat hij telkens een nieuwe verbinding opent en deze vervolgens sluit. (Closing connection 0#) Iemand ideeën?
Tot nu toe heb ik het onderstaande script alleen lijkt het erop dat hij telkens een nieuwe verbinding opent en deze vervolgens sluit. (Closing connection 0#) Iemand ideeën?
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| // Request data $url = "http://url.nl"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $curl = curl_init(); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_FRESH_CONNECT, false); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_FORBID_REUSE, 0); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_URL, $url); while(true){ $result = curl_exec($curl); print($result); sleep(30); } |