|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-17 00:16 UTC] colder@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 12 23:00:01 2026 UTC |
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