php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10304 Garbled Data/timeout with UDP-Socket
Submitted: 2001-04-12 11:06 UTC Modified: 2001-12-13 06:24 UTC
From: jorfen at topmail dot de Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.0.4pl1 OS: Linux2.2.12
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jorfen at topmail dot de
New email:
PHP Version: OS:

 

 [2001-04-12 11:06 UTC] jorfen at topmail dot 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-02 21:42 UTC] 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-11-21 12:14 UTC] mfischer@php.net
Can you try with latest RC and see if it works

http://www.php.net/~zeev/php-4.1.0RC3.tar.gz

Feedback.

 [2001-12-13 06:24 UTC] sander@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC