ID:               27466
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tleaver at synchronics dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Sockets related
 Operating System: Windows XP
 PHP Version:      4.3.4
 New Comment:

>From http://www.php.net/fread



------------------------------

fread() reads up to length bytes from the file pointer referenced by
handle. Reading stops when length bytes have been read, EOF (end of
file) is reached, or (for network streams) when a packet becomes
available, whichever comes first. 

------------------------------



The length parameter for fread is a MAXIMUM length to be read, not a
minimum or an exact.



If you're expecting a specific number of bytes, you should use a loop
to repeatedly call fread() each itteration of which returns a new
network packet.



Note also that this is a duplicate bug report.  The exact behavior you
describe has been reported and documented on bugs.php.net already.


Previous Comments:
------------------------------------------------------------------------

[2004-03-02 13:48:49] tleaver at synchronics dot com

Description:
------------
We have a commercial PHP-based product, basically a web app which
interfaces with our Counterpoint point of sale product, and is designed
to run on wireless handheld devices.



Communications with Counterpoint is handled via an application server,
which we communicate with from PHP via a socket connection.



Of the different types of messages we pass back and forth between PHP
and the application server, is a transaction describing a complex item
with multiple dimensions (size, color, etc).  When retreiving this
large block of data from the socket using fread, we get unexpected
data.



Each packet which is exchanged consists of a beginning 1 byte marker
("\x02") which denotes the beginning of a package, followed by a
protocol version (internal designator), followed by 2 bytes indicating
the length of the packet.  We then fread that number of bytes from the
socket, followed by 12 bytes of additional data tacked onto the end of
the information.



Certain communications are multi-packet, so the code loops until we
either hit an feof condition or do not receive the expected beginning
marker (which is an error).



Using PHP 4.3.1 and earlier, down to 4.1.1, the code works fine.  With
PHP 4.3.2 and newer, including 4.3.5RC3, the code chokes on large
packets.



That's as precise as I've been able to be to date.  We are not using a
debug tool as of yet, so I can't be very precise.  The code necessary
to reproduce the problem would require Counterpoint and our application
server be installed, which isn't feasible.



Perhaps someone could look for changes in fread since 4.3.1 and see if
there is a problem?



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27466&edit=1

Reply via email to