From:             flugelaar at pandora dot be
Operating system: Linux Slackware 9.0
PHP version:      5CVS-2003-08-29 (dev)
PHP Bug Type:     Sockets related
Bug description:  stream_set_blocking() doesn't set non-blocking mode

Description:
------------
Fgets() keeps blocking when I try to make a socket from
stream_socket_accept() non-blocking. The listening socket is also
non-blocking.

Reproduce code:
---------------
This code is still blocking on the fgets:

    $conn = @stream_socket_accept($hsock,1,&$host);
    if (!$conn) return;
    echo "Got connection from ".$host."\n";
    stream_set_blocking($conn,false);
    $get = '';
    $loop = 0;
    while ($loop <= 10) { $getl = trim(fgets($conn)); $loop++; if
(empty($getl)) { echo "End of headers\n"; break; }else{ $get .=
$getl."\n"; } }

This is the code that created the $hsock :

$hsock = stream_socket_server('tcp://'.$bind.':'.$port, $errno, $errstr);
if (!$hsock) die ('Listening socket failed: '.$errstr);
if (!socket_set_blocking($hsock,false)) echo "Socket (listening) set
nonblock failed\n";

$bind is 0.0.0.0 and port is 3333

Expected result:
----------------
It shouldn't hang on the fgets() because this script handles two sockets.
And the other one times out when fgets() hangs untill something is
recieved.

Actual result:
--------------
Fgets() keeps blocking so my other connection times out.

-- 
Edit bug report at http://bugs.php.net/?id=25309&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25309&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25309&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25309&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25309&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25309&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25309&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25309&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25309&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25309&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25309&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25309&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25309&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25309&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25309&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25309&r=gnused

Reply via email to