php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4135 Non-blocking fgets() on socket not returning.
Submitted: 2000-04-13 13:43 UTC Modified: 2002-10-01 15:04 UTC
From: itbryant at asedata dot bbn dot hp dot com Assigned:
Status: Wont fix Package: Misbehaving function
PHP Version: 3.0.16 OS: NT4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: itbryant at asedata dot bbn dot hp dot com
New email:
PHP Version: OS:

 

 [2000-04-13 13:43 UTC] itbryant at asedata dot bbn dot hp dot 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";
}
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-01 15:04 UTC] hholzgra@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC