#4135 [Opn->]: Non-blocking fgets() on socket not returning.

From: Date: Tue, 01 Oct 2002 20:04:43 +0000
Subject: #4135 [Opn->]: Non-blocking fgets() on socket not returning.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-21115@lists.php.net to get a copy of this message
ID: 4135 Updated by: hholzgra@php.net Reported By: itbryant@asedata.bbn.hp.com -Status: Open +Status: Won\'t fix Bug Type: Misbehaving function Operating System: NT4 PHP Version: 3.0.16 New Comment: We are sorry, but can not support PHP 3 related problems anymore. Momentum is gathering for PHP 5, and we think supporting PHP 3 will lead to a waste of resources which we want to put into getting PHP 5 ready. Ofcourse PHP 4 will will continue to be supported for the forseeable future. Previous Comments: ------------------------------------------------------------------------ [2000-04-13 13:43:18] itbryant@asedata.bbn.hp.com 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"; } ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=4135&edit=1

« previous php.bugs (#21115) next »