php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28741 fread() - end of UDP packets
Submitted: 2004-06-11 15:32 UTC Modified: 2004-07-24 18:54 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: iqomm at users dot sourceforge dot net Assigned:
Status: Closed Package: *Network Functions
PHP Version: 5.0.0RC2 OS: Windows XP, Apache 1.3.27
Private report: No CVE-ID: None
 [2004-06-11 15:32 UTC] iqomm at users dot sourceforge dot net
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-13 14:02 UTC] iqomm at users dot sourceforge dot net
Changed OS: All (?) to OS: Windows XP, Apache 1.3.27
 [2004-07-24 18:54 UTC] iqomm at users dot sourceforge dot net
Seems to be fixed in 5.0 final and later (CVS). Closing.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon May 20 20:01:27 2019 UTC