ID: 43325 User updated by: mertcan at dpozitif dot com Reported By: mertcan at dpozitif dot com -Status: Feedback +Status: Open Bug Type: Streams related Operating System: Centos 5.0 PHP Version: 5.2.5 New Comment:
actually if i set stream_set_blocking for $fp to 1 it gives the result (which i posted the code below) if i change stream_set_blocking to 0, it does not give any result. in either ways if i use feof($fp) it hangs.. <?php echo rcon_komut("meta list", "123456", "62.68.207.16", 27015); function rcon_komut($komut, $rcon_pass, $ip, $port) { $response = ""; $msg = "ÿÿÿÿchallenge rcon"; $fp = fsockopen("udp://".$ip,$port, $errno, $errstr); stream_set_blocking($fp, 1); fputs($fp, $msg, strlen($msg)); $response .= fgets($fp, 1024); fclose ($fp); return $response; } ?> Previous Comments: ------------------------------------------------------------------------ [2007-11-20 09:29:54] [EMAIL PROTECTED] Your script doesn't work because you don't get anything in $response in the first place. So you're passing invalid data around long before feof() is used and the server just sits there propably waiting for more data to be input before it gives any back.. ------------------------------------------------------------------------ [2007-11-20 09:10:45] mertcan at dpozitif dot com Here is the full program: <?php echo rcon_komut("meta list", "123456", "62.68.207.16", 27015); function rcon_komut($komut, $rcon_pass, $ip, $port) { $response = ""; $msg = "ÿÿÿÿchallenge rcon"; $fp = fsockopen("udp://".$ip,$port, $errno, $errstr); stream_set_blocking($fp, 0); fputs($fp, $msg, strlen($msg)); $response = fgets($fp, 1024); $challenge = substr($response, 19, strlen($response) - 20); $msg="ÿÿÿÿrcon".$challenge."\"".$rcon_pass."\"".$komut.chr(0); fputs($fp, $msg, strlen($msg)); while (!feof($fp)) $response .= fgets($fp, 4096); fclose ($fp); return $response; } ?> ------------------------------------------------------------------------ [2007-11-20 08:44:44] [EMAIL PROTECTED] That's still just a piece of the script, a proper test script starts with <?php and ends in ?> and can be just copy'pasted and run.. ------------------------------------------------------------------------ [2007-11-19 17:19:22] mertcan at dpozitif dot com i gave $tanim in function use: function rcon_komut($komut, $rcon_pass, $ip, $port) { $msg = "ÿÿÿÿchallenge rcon"; $fp = fsockopen("udp://".$ip,$port, $errno, $errstr); stream_set_blocking($fp, 0); fputs($fp, $msg, strlen($msg)); $response = fgets($fp, 1024); $challenge = substr($response, 19, strlen($response) - 20); $msg="ÿÿÿÿrcon".$challenge."\"".$rcon_pass."\"".$komut.chr(0); fputs($fp, $msg, strlen($msg)); while (!feof($fp)) $response .= fgets($fp, 32); fclose ($fp); $response = substr($response, 6, strlen($response)-6); return $response; } ------------------------------------------------------------------------ [2007-11-19 16:31:10] [EMAIL PROTECTED] Well, can you give a script that has some possibility of working properly? In the give script you have at least one variable which is not set anywhere: $komut ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/43325 -- Edit this bug report at http://bugs.php.net/?id=43325&edit=1