PHP socket link, can I set the time?
PHP Code
$socket = Socket_create (Af_inet, Sock_stream, sol_tcp); $IP = $row [' IP ']; $connection = Socket_connect ($socket, $IP, 2012);
It seems that the default is 30 seconds, if not even the time is too long, can you set it only 10 seconds?
------Solution--------------------
The user annotation area of the online manual has a lot of useful references, you can search for timeout in the http://php.net/manual/en/function.socket-get-option.php, because this problem is very common, so there is certainly.
If you're lazy, extract a piece of code for you
So_sndtimeo Reports The timeout value specifying the amount of time that an output function blocks because flow contro l prevents data from being sent.array. The array would contain keys:sec which is the seconds part on the timeout value and USEC which are the microsecond part of the timeout value.
To set a socket timeout value (assuming you ' ve set it blocking) use:
PHP code
socket_set_option ($socket, sol_socket,//Socket Lev El So_sndtimeo,//timeout Option Array ("SEC" =>10,//timeout in seconds "usec" =>0//I-assume timeout in microseconds));
------Solution--------------------
discussion
Reference:
User Comment area of the online manual there's actually
A lot of useful references, you can search for timeout in the http://php.net/manual/en/function.socket-get-option.php, because this problem is very common, so there will certainly be.
If you're lazy, extract a piece of code to you
So_sndtimeo Reports The timeout value specifying ...
------Solution--------------------
to put the connected PHP code in a separate file, with Ajax access, and put the result in a DIV