|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11271 low-level socket read() doesn't work properly
Submitted: 2001-06-04 19:02 UTC Modified: 2001-06-05 01:36 UTC
From: rumblepipe at altavista dot com Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.0.4 OS: Linux 2.2.18
Private report: No CVE-ID: None
 [2001-06-04 19:02 UTC] rumblepipe at altavista dot com
configure --enable-sockets --with-apache=../apache --with-mysql

usage: typical C-style socket instantiation, write() the output, shutdown() on the write half (which tells the other end the transaction is done), read() (wait for the response), close.

The read absorbs junk before, throughout, and after the transaction return, and times out after 30 seconds, having read a WHOLE LOT of stuff it shouldn't.

This may have been fixed with 4.0.5, but I didn't get to test it thoroughly, because 4.0.5's mysql interface is broken.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-05 01:36 UTC]
Without seeing the code I assume this is a quite common
problem, mostly because lack of documentation.

I have already added this to the CVS of the documentation
but as the main servers are still down the online manual
doesn't get updated. 

There is a 4th argument for read() which takes these 
three constants:

PHP_READ_SYSTEM - use the system read()
PHP_READ_BINARY - binary safe read() (same as PHP_READ_SYSTEM)
PHP_READ_NORMAL - Default. Reading stops at \n or \r.

So using the read like this:

read($fd, $buffer, $len, PHP_READ_SYSTEM)

should give you the same behaviour as C-style read() is.


PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 19 06:05:44 2022 UTC