|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36796 Streams blocking after set non-blocking
Submitted: 2006-03-20 06:37 UTC Modified: 2007-07-17 13:30 UTC
From: seufert at gmail dot com Assigned: jani (profile)
Status: Closed Package: Streams related
PHP Version: 5.1.2 OS: AMD64 Linux 2.6 (Debian)
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: seufert at gmail dot com
New email:
PHP Version: OS:


 [2006-03-20 06:37 UTC] seufert at gmail dot com
Opening a TCP stream, and attempting to access in a non-blocking matter results in fread continuing to block.

Reproduce code:
$socket = stream_socket_server('tcp://');
stream_set_blocking($socket, 0);
$conns = array(); $text = "";
  $new_connection = @stream_socket_accept($socket, 0);
  print "T";
  else {
   $conns[] = $new_connection;
  foreach($conns as $k=>$c) $text .= fread($conns[$k], 8192);
  foreach($conns as $c) fwrite($c,$text);
  $text = "";

Expected result:
After connecting once or more (with telnet or similar), the program should still tick (will print 'T' to console).

Actual result:
Once 1 or more connections are established, the fread blocks, and prevents the program from iterating (or printing 'T' to the console). It will iterate after data is received from all connections.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-10 12:38 UTC]
Wez, here's another one.
 [2007-07-17 13:30 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC