From: xrstf-misc at yahoo dot com
Operating system: Linux (ARM)
PHP version: 5.4.5
Package: Sockets related
Bug Type: Bug
Bug description:stream_socket_accept does not block
Description:
------------
I'm opening a socket on 0.0.0.0, port 8080 (doesn't matter) and then I'm
trying
to accept incoming connections. For this, the stream_socket_accept()
function
should block and wait for connections.
This works on Windows and Linux (x86), but on ARM it fails. For some
reason, the
functions returns immediately, generating a warning:
stream_socket_accept(): accept failed: Connection timed out
Setting the timeout in my testscript to 0 doesn't change anything. Setting
the
timeout to a non-infinite one like 10 seconds makes the function block
correctly
for 10 seconds.
The problem occurs in all PHP 5.4 versions. I didn't test 5.3 or earlier.
Test script:
---------------
<?php
$addr = "tcp://0.0.0.0:8080";
$errno = null;
$errstr = null;
print "\n";
print " > Creating socket @ $addr...";
$socket = stream_socket_server($addr, $errno, $errstr);
if ($socket === false) {
print " ERROR: $errstr ($errno)\n\n";
exit(2);
}
print " OK :)\n";
print " > Accepting incoming connections (listening)...";
$conn = stream_socket_accept($socket, -1);
print " ERROR: should not have reached this point!\n\n";
exit(1);
Expected result:
----------------
The script should stop and wait at the stream_socket_accept() call forever.
Actual result:
--------------
The function returns false and throws a warning.
--
Edit bug report at https://bugs.php.net/bug.php?id=62816&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62816&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62816&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62816&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62816&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62816&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62816&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62816&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62816&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62816&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62816&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62816&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62816&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62816&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62816&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62816&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62816&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62816&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62816&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62816&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62816&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62816&r=mysqlcfg