From: iqomm at users dot sourceforge dot net
Operating system: All (?)
PHP version: 5.0.0RC2
PHP Bug Type: *Network Functions
Bug description: fread() - end of UDP packets
Description:
------------
I use PHP for some UDP gamequery scripts. Everything works OK in PHP 4.x,
but the new PHP 5 RCs' fread() seems to act greedily once again. Checked
the CVS version (Jun 11, 2004 06:30 GM) - the same.
I think it is a duplicate of (or very similar to) Bug #15639 (detecting
end of UDP packets) which was fixed in PHP 4.3.2.
Reproduce code:
---------------
// Just an example query
// :1 - blocking socket
$handle = fsockopen("udp://195.149.21.70", 27015);
fwrite($handle, "\xFF\xFF\xFF\xFFrules\x00");
$data = fread($handle, 8192);
// It just hangs
// :2 - non-blocking socket
$handle = fsockopen("udp://195.149.21.70", 27015);
stream_set_blocking($handle, FALSE);
fwrite($handle, "\xFF\xFF\xFF\xFFrules\x00");
sleep(1);
$data = fread($handle, 8192);
// Returns more than 1 packet
Expected result:
----------------
Should work just as in PHP 4.3.7:
Case 1 - blocking socket:
Returns the less of one packet or max length.
Case 2 - non-blocking:
Returns just one packet.
--
Edit bug report at http://bugs.php.net/?id=28741&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28741&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28741&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28741&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28741&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28741&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28741&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28741&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28741&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28741&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28741&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28741&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28741&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28741&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28741&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28741&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28741&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28741&r=float