Edit report at https://bugs.php.net/bug.php?id=63099&edit=1
ID: 63099 Updated by: ras...@php.net Reported by: prggmr at gmail dot com Summary: stream_socket_accept does not respect float seconds -Status: Closed +Status: Not a bug Type: Bug Package: Streams related Operating System: Mac OSX/Unix PHP Version: 5.4.7 Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2012-09-16 14:55:27] prggmr at gmail dot com Disregard .. my math was wrong :) ------------------------------------------------------------------------ [2012-09-16 14:43:41] prggmr at gmail dot com Description: ------------ --- >From manual page: http://www.php.net/function.stream-socket-accept#refsect1- function.stream-socket-accept-description --- stream_socket_accept does not properly timeout given a floated time under 0 seconds. The documentation states it does accept a float and should be given in seconds, so a timeout such as .0010 should be valid and used. Test script: --------------- /** * Stream socket accept does not accept floats as documented */ function milliseconds(/* ... */) { return round(microtime(true) * 1000); } $socket = stream_socket_server('tcp://127.0.0.1:5000', $errno, $errstr); stream_set_blocking($socket, 0); echo "START TIME".PHP_EOL; echo milliseconds().PHP_EOL; while(false !== $connect = @stream_socket_accept($socket, .0010)) { } echo "END TIME".PHP_EOL; echo milliseconds().PHP_EOL; echo "START TIME".PHP_EOL; echo milliseconds().PHP_EOL; usleep(10 * 1000); echo "END TIME".PHP_EOL; echo milliseconds().PHP_EOL; Expected result: ---------------- START TIME 1347806197759 END TIME 1347806197769 START TIME 1347806197760 END TIME 1347806197770 Actual result: -------------- START TIME 1347806197759 END TIME 1347806197760 START TIME 1347806197760 END TIME 1347806197770 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63099&edit=1