From:             thejoshes at josh dot com
Operating system: OS X 10.2.3
PHP version:      4.3.1
PHP Bug Type:     Sockets related
Bug description:  socket_set_blocking() won't work?

The following script produces this error:

<b>Warning</b>:  socket_set_blocking(): supplied resource is not a valid
stream resource in <b>/Users/josha/test/noblock.php</b> on line
<b>10</b><br />

Even though the socket connection will work fine... I expect this to work,
since $s is indeed a valid stream resource, right?

#!/usr/local/bin/php
<?php

$HOST = 'localhost';
$PORT = 4005;

# set up the server
$s = socket_create(AF_INET, SOCK_STREAM, 0);
$ret = socket_bind($s, $HOST, $PORT);
$ret = socket_set_blocking($s, false); // why is this an issue?
$ret = socket_listen($s, 1);
echo "Waiting for connection(s) on PORT $PORT...\n";

while (!$done) {
        $u = pollNewConn();
        echo "$u\n";
}

function pollNewConn() {
        global $s;

        if ($conn = socket_accept($s)) {
                return "Connected";
        } else {
                return "No connection";
        }
} 
?>
-- 
Edit bug report at http://bugs.php.net/?id=22656&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22656&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22656&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22656&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22656&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22656&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22656&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22656&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22656&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22656&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22656&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22656&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22656&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22656&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22656&r=gnused

Reply via email to