Bug #10304 Updated: Garbled Data/timeout with UDP-Socket
| From: | mfischer@php.net | Date: | Wed, 21 Nov 2001 17:14:31 +0000 |
| Subject: | Bug #10304 Updated: Garbled Data/timeout with UDP-Socket | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71265@lists.php.net to get a copy of this message | ||
ID: 10304
Updated by: mfischer
Reported By: jorfen@topmail.de
Old Status: Open
Status: Feedback
Bug Type: Sockets related
Operating System: Linux2.2.12
PHP Version: 4.0.4pl1
New Comment:
Can you try with latest RC and see if it works
http://www.php.net/~zeev/php-4.1.0RC3.tar.gz
Feedback.
Previous Comments:
------------------------------------------------------------------------
[2001-06-02 21:42:00] sniper@php.net
For now, I suggest you use the sockets extensions functions:
function foo2($ip,$port)
{
$sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
$retval=connect($sock,$ip,$port);
write($sock, "ÿÿÿÿinfo\x00", 11);
$numread=read($sock,$readdata,10000,
PHP_BINARY_READ);
close $sock;
return $readdata;
}
This works for me just fine.
Seems the f-funcs don't work as expected with UDP.
--Jani
------------------------------------------------------------------------
[2001-04-12 11:06:52] jorfen@topmail.de
1)
<?
function foo($ip,$port)
{
$fp = fsockopen("udp://".$ip,$port);
fwrite($fp,"ÿÿÿÿinfo\x00");
$a = fread($fp,5000);
fclose($fp);
}
?>
This code is for querying a HalfLife-Server (left out if
($fp) ...).
The script works till it tries to read from the socket.
PHP reads a part of the string the server should return
and hangs till the socket times out.
The same method in C, Perl etc works perfectly so I assume
there is a problems with PHP and UDP-Sockets.
2)
Trying to read multiple lines from a server connected to
with an UDP-Socket give garbled Data+Timeout.
Again C, Perl work perfectly.
(recent version from CVS do not work, too)
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=10304&edit=1