Default_socket_timeout configuration in PHP ... ____php

Source: Internet
Author: User

Recently in the study of some POC, found that most of the POC will have such a ini_set (' Default_socket_timeout ', 5), meaning that the configuration Default_socket_timeout set the parameters of 5. Do not know what the meaning of this configuration, to the official online check, given the explanation is very simple default timeout (in seconds) for socket based streams. The timeout for the socket stream (the parameter is in seconds). I want to try this effect, but search for a long time, there is no domestic and foreign countries can reflect the significance of this parameter examples. So casually found a simple code to try the following, the code is as follows:
\<\?php $url = ' Http://www.cnblogs.com/Zjmainstay/archive/2012/03/08/PHP_FUN ction_file_get_contents.html ';   Ini_set (' Default_socket_timeout ', 3); if ($data = file_get_contents ($url)) {echo $data;} else {echo ' Timeout ';} \?\>
The meaning is very simple, is to get a page, the socket stream time set to 3 seconds, the effect is as follows

Later I will change the default_socket_timeout time to 0.1 seconds, that is, Ini_set (' Default_socket_timeout ', 0.1), and then access, the effect is as follows

In writing this article, suddenly found that the original PHP official web site on this set of sample code, and I compare the experiment to see it.




        through search explanations and experimental tests, I get the conclusion that the Default_socket_timeout is the timeout parameter for the socket stream, That is, the socket stream from the establishment to the transfer to the closure of the entire process must be within the time set by this parameter, if not complete, then PHP will automatically end the socket and return a warning. A similar PHP configuration is connection_timeout, but connection_timeout means that the time to keep the connection timed out does not include creating and destroying connections.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.