From: jason at superlink dot net Operating system: FreeBSD 4.8 PHP version: 4.3.2 PHP Bug Type: Reproducible crash Bug description: socket_read() in PHP_NORMAL_READ exits abnormally
I'm running a socket connection that needs NORMAL_READ mode enabled. Here is a sample of the socket connection: <?php while(1){ $r = array($socket); if(socket_select($r, $w, $except = NULL, 0)) { if($buffer = socket_read($socket, 2048, PHP_NORMAL_READ)) { $data=trim($buffer); dostuff($data);// do something with the data. } else { // for some reason my socket connection FAILS a lot. die("ERROR: failed to read socket to $remotehost"); } } else { sleep(1); } } ?> In the event of an error, I've been logging the error: socket_strerror(socket_last_error()) The error for the last 5 attempts has returned: uptime: 211 Unknown error: 0 uptime: 439 Unknown error: 0 uptime: 275 Unknown error: 0 uptime: 279 Unknown error: 0 uptime: 395 Unknown error: 0 The socket connection doesn't seem to want to stay alive for long. The error message seems.... very unfriendly. I've tried the program in binary mode (while my program doesn't function with binary mode on, it can still download and read from the socket). In binary mode, the problem does not occur. I've tried NORMAL_READ with and without socket blocking, with the same results (unexplained socket error). this problem seems to have been happening in php 4.3.1 too. Configure Command './configure' '--prefix=/usr/local' '--with-apache=/home/jason/apache_1.3.27' '--enable-exif' '--enable-track-vars' '--with-calendar=shared' '--enable-magic-quotes' '--enable-trans-sid' '--enable-wddx' '--enable-sockets' '--disable-debug' '--enable-gd-native-tt' '--with-zlib' '--enable-inline-optimization' '--enable-memory-limit' '--with-mysql=/usr/local' -- Edit bug report at http://bugs.php.net/?id=24066&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24066&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24066&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24066&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24066&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24066&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24066&r=support Expected behavior: http://bugs.php.net/fix.php?id=24066&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24066&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24066&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24066&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24066&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24066&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24066&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24066&r=gnused