function fsockopen_test(){ $hostname = 'm.cn'; $url = '/test/1.php'; $fp = fsockopen($hostname, 80, $errno, $errstr, 5); if (!$fp) { echo "$errstr ($errno)"; return false; } stream_set_blocking($fp,0);//开启了手册上说的非阻塞模式 $header = "GET $url HTTP/1.1\r\n"; $header.="Host: $hostname\r\n"; $header.="Connection: Close\r\n\r\n";//长连接关闭 fwrite($fp, $header); fclose($fp);}fsockopen_test();
sleep(6);$fp = fopen ( './data.txt' , 'w' );fwrite ( $fp ,111);fclose ( $fp );
没问题呀
echo date('Y-m-d H:i:s'), PHP_EOL;fsockopen_test();echo date('Y-m-d H:i:s'), PHP_EOL;
没问题呀
echo date('Y-m-d H:i:s'), PHP_EOL;fsockopen_test();echo date('Y-m-d H:i:s'), PHP_EOL;
没问题呀
echo date('Y-m-d H:i:s'), PHP_EOL;fsockopen_test();echo date('Y-m-d H:i:s'), PHP_EOL;
没问题呀
echo date('Y-m-d H:i:s'), PHP_EOL;fsockopen_test();echo date('Y-m-d H:i:s'), PHP_EOL;
function fsockopen_test(){ $hostname = 'm.cn'; $url = '/test/1.php'; $fp = fsockopen($hostname, 80, $errno, $errstr, 5); if (!$fp) { echo "$errstr ($errno)"; return false; } stream_set_blocking($fp,0);//开启了手册上说的非阻塞模式 $header = "GET $url HTTP/1.1\r\n"; $header.="Host: $hostname\r\n"; $header.="Connection: Close\r\n\r\n";//长连接关闭 fwrite($fp, $header); /*$html = ''; while (!feof($fp)) { $html.=fgets($fp); } echo $html;*/ fclose($fp);}echo time(),'<br>';fsockopen_test();echo time(),'<br>';