Bug #4135: Non-blocking fgets() on socket not returning.

From: Date: Thu, 13 Apr 2000 17:43:18 +0000
Subject: Bug #4135: Non-blocking fgets() on socket not returning.
Groups: php.dev 
Request: Send a blank email to php-dev+get-17886@lists.php.net to get a copy of this message
From: itbryant@asedata.bbn.hp.com Operating system: NT4 PHP version: 3.0.16 PHP Bug Type: Misbehaving function Bug description: Non-blocking fgets() on socket not returning. I notice a number of people have had this problem with various OSes, and it was reported fixed (in 3.0.12, for Linux). Our code works fine on Linux, but fgets() doesn't return on NT for a socket with non-blocking set - even if there is data to be read. I even tried adding in a usleep(), which seems to be necessary for consecutive socket reads (on Linux too) - see #3719 about that. Also: feof() on the same socket (instead of fgets()) doesn't return either on NT. Maybe this is related. We're using the bog-standard precompiled win32 version, with only a couple of paths changed in the INI file, and IIS. -- Steve Obligatory script: <?php header("Content-type: text/plain"); $smtp_server = "127.0.0.1"; // Change this!!! $sd = fsockopen( $smtp_server, 25, &$errno, &$errstr, 3 ); if ( !$sd ) { print "not open: $errstr\n"; } else { // NT/IIS uses COMPUTERNAME instead of HOSTNAME $line = "> HELO " . getenv( "COMPUTERNAME" ) . "\n"; print $line; fputs( $sd, $line ); set_socket_blocking( $sd, TRUE ); $line = fgets( $sd, 4096 ); set_socket_blocking( $sd, FALSE ); while ( $line != "" ) { print "< $line"; flush(); // Hangs here: $line = fgets( $sd, 4096 ); print "Got something!\n"; } print "The End.\n"; } ?>

« previous php.dev (#17886) next »