Bug #63099 [Csd->Nab]: stream_socket_accept does not respect float seconds
| From: | rasmus@php.net | Date: | Sun, 16 Sep 2012 14:59:10 +0000 |
| Subject: | Bug #63099 [Csd->Nab]: stream_socket_accept does not respect float seconds | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173485@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63099&edit=1
ID: 63099
Updated by: rasmus@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