Bug #13122: UDP probs

From: Date: Tue, 04 Sep 2001 08:38:25 +0000
Subject: Bug #13122: UDP probs
Groups: php.dev 
Request: Send a blank email to php-dev+get-65030@lists.php.net to get a copy of this message
From:             beorn@ligarena.com
Operating system: linux red hat 7.1
PHP version:      4.0.4pl1
PHP Bug Type:     Sockets related
Bug description:  UDP probs

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;
}
//---------------------------------------------------------
-- 
Edit bug report at: http://bugs.php.net/?id=13122&edit=1



Thread (3 messages)

« previous php.dev (#65030) next »