note 90343 modified in function.socket-accept by danbrown

From: Date: Fri, 17 Apr 2009 16:53:27 +0000
Subject: note 90343 modified in function.socket-accept by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153447@lists.php.net to get a copy of this message
Beware 'socket_accept' does not return false; instead it returns NULL on error: <?php # accept the client and create a new socket if (($new_socket = @socket_accept($master_socket))===false) { echo "I should be here; but I'm not."; } var_dump($master_socket); var_dump($new_socket); ?> ================== CLI OUTPUT: array(1) { [0]=> resource(20) of type (Socket) } NULL ================== Where $master_socket should be a single resource. --was-- How annoying... w/ PHP 5.2.9 linux. Beware 'socket_accept' does not return false; instead it returns NULL on error: # accept the client and create a new socket if (($new_socket = @socket_accept($master_socket))===false) { echo "I should be here; but I'm not."; } var_dump($master_socket); var_dump($new_socket); ================== CLI OUTPUT: array(1) { [0]=> resource(20) of type (Socket) } NULL ================== Where $master_socket should be a single resource. http://php.net/manual/en/function.socket-accept.php

« previous php.notes (#153447) next »