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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
21 - 1 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Sun Jun 16 17:01:29 2024 UTC