Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP's curl_reset() close the underlying connection?

Tags:

php

curl

I am doing many curl requests to the same server in a loop.

I want to keep using the same curl handle, as this is much faster than closing it with curl_close() and getting a new one using curl_init() as it keeps the underlying connection open. Reusing the handle is definitely faster.

If I call curl_reset() after each request, will this reset the connection and therefore slow down?

like image 887
Liam Avatar asked Nov 16 '16 21:11

Liam


People also ask

What is the use of curl() function in PHP?

This function has no effect. Prior to PHP 8.0.0, this function was used to close the resource. Closes a cURL session and frees all resources. The cURL handle, handle, is also deleted. A cURL handle returned by curl_init ().

What happens to the curl handle when you delete it?

The cURL handle, handle, is also deleted. A cURL handle returned by curl_init (). No value is returned. handle expects a CurlHandle instance now; previously, a resource was expected.

What is the use of curl_close()?

curl_close (CurlHandle $handle): void Closes a cURL session and frees all resources. The cURL handle, handle, is also deleted.

What is the value of curl handle returned by Curl_init()?

A cURL handle returned by curl_init (). No value is returned. handle expects a CurlHandle instance now; previously, a resource was expected. There are no user contributed notes for this page.


1 Answers

No. The curl_reset engine code calls the libcurl method curl_easy_reset whose documentation explicitly states:

... does not change the following information kept in the handle: live connections, the Session ID cache, the DNS cache, the cookies and shares.

like image 90
bishop Avatar answered Oct 19 '22 19:10

bishop