php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13122 UDP probs
Submitted: 2001-09-04 04:38 UTC Modified: 2001-09-05 05:06 UTC
From: beorn at ligarena dot com Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.0.4pl1 OS: linux red hat 7.1
Private report: No CVE-ID: None
 [2001-09-04 04:38 UTC] beorn at ligarena dot com
well when i send an UDP packet to my halflife server with 
fsockopen and fgets, it returns me another packet beginning from the 2nd line instead of the 1st. it means that if i were supposed to get :

packet #1-"hello"
packet #2-"world"
packet #3-"its me"

i receive :

packet #1-"world"
packet #2-"its me"


here's a sample of my code :
//---------------------------------------------------------

function get_pass_player_cs($serverip,$port,$rcon)
{

	$get_pass_player_cs .= "<BR>Do ".$commande." on :".$serverip.":".$port.'<BR><BR>';

	//Open the network for transmission. 
	$serverip = "udp://".$serverip;
	$fp = fsockopen($serverip,$port, &$errno, &$errstr,10);
	if (!$fp) 
	{ 
		$get_pass_player_cs .= "Server not available :".$errno;
	} 
	else 
	{ 
		//Send statusrequest. 
		fwrite($fp,"????challenge rcon"."\x00");
		$challenge = fgets($fp,50);
		$challenge = substr($challenge, 19);
		$challenge = trim ($challenge);
		$rcontxt="????rcon ".$challenge." ".$rcon." status\x00";
		fwrite($fp,$rcontxt);

		$tmp = fgets($fp,100);
//debug		echo $tmp;
		
		$get_pass_player_cs = $tmp;
		
		fclose($fp);
		return $get_pass_player_cs;
	}
	$get_pass_player_cs .= "Erreur";
	fclose($fp);
	return $get_pass_player_cs;
}
//---------------------------------------------------------

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-04 18:30 UTC] sniper@php.net
You fread() instead which is binary safe.

--Jani


 [2001-09-05 05:06 UTC] beorn at ligarena dot com
the problem is that i cant get the amount of bytes to receive its UDP !
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 21:03:42 2022 UTC