|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-10-01 15:04 UTC] hholzgra@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
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"; } ?>