#40147 [NEW]: Bad Socket Example

From: Date: Tue, 16 Jan 2007 17:53:18 +0000
Subject: #40147 [NEW]: Bad Socket Example
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969374848@lists.php.net to get a copy of this message
From: bnewton at networkmerchants dot com Operating system: LINUX PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: Bad Socket Example Description: ------------ The first example on the Sockets section of the manual uses socket_bind and socket_listen incorrectly. They manual page for each function correctly states that they return BOOLEAN values, not error return codes. That means the lines: if (($ret = socket_bind($sock, $address, $port)) < 0) { echo "socket_bind() failed: reason: " . socket_strerror($ret) . "\n"; } if (($ret = socket_listen($sock, 5)) < 0) { echo "socket_listen() failed: reason: " . socket_strerror($ret) . "\n"; } Will not fail, if there is an error. If they did fail, they would not report any meaningful error message (error 0 ie false is "success"). Reproduce code: --------------- if (($ret = socket_bind($sock, $address, $port)) < 0) { echo "socket_bind() failed: reason: " . socket_strerror($ret) . "\n"; } if (($ret = socket_listen($sock, 5)) < 0) { echo "socket_listen() failed: reason: " . socket_strerror($ret) . "\n"; } Expected result: ---------------- If the socket is not available it should stop the execution of the script and display a meaningful error message. Actual result: -------------- It will continue to run the code below, even if there really was an error. If it did stop, it would not print the correct error message -- Edit bug report at http://bugs.php.net/?id=40147&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40147&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40147&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40147&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40147&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40147&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40147&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40147&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40147&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40147&r=support Expected behavior: http://bugs.php.net/fix.php?id=40147&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40147&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40147&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40147&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40147&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40147&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40147&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40147&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40147&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40147&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40147&r=mysqlcfg

« previous php.doc (#969374848) next »