PHP에서 스트림을 열고 쓰기 작업을하고 있습니다. 스트림의 독서에 타임 아웃을 설정하고 싶지만 메타 데이터가 "timed_out"을 표시하지는 않습니다 (0 마이크로 초, 10 마이크로 초).stream_set_timeout은 제한 시간이 얼마되지 않아도 작동하지 않습니다.
관련 코드 : 내가 잘못
//open the socket
if ($fp = fsockopen(gethostbyname(host), port, $errno, $errstr, $timeout)) {
//Send command to the host
if (fwrite($fp, $requestCommand)) {
//Set timeout and blocking
stream_set_blocking($fp, FALSE);
stream_set_timeout($fp, 0, 10);
//Check for timeout
$info = stream_get_meta_data($fp);
echo $info[ 'timed_out' ];
//Read and check for timeout
while (!$info['timed_out'] && !feof($fp)) {
$response .= fread($fp, 4096);
//Get meta data (which has timeout info)
$info = stream_get_meta_data($fp);
}
}
}
을 뭐하는 거지?
CLI 또는 브라우저에서이 작업을 실행하고 있습니까? – Pheonix