frozenfire89 Posted May 15, 2007 Share Posted May 15, 2007 Ok, this is specific to the Half-Life game engine, so anyone with no experience in such may not be able to help. Here is my script: $ServerIP = "8.6.3.239"; $ServerPort = "27015"; $ServerinfoCommand = "\377\377\377\377infostring\0"; $fp = fsockopen("udp://".$ServerIP, $ServerPort, $errno, $errstr); stream_set_timeout($fp, 10); fwrite($fp, $ServerinfoCommand); $JunkHead = fread($fp,24); $CheckStatus = socket_get_status($fp); if($CheckStatus["unread_bytes"] == 0) { die("A connection to the server could not be made."); } $do = 1; $HLServerStats= ""; while($do) { $str = fread($fp,1); $HLServerStats.= $str; $CheckStatus = socket_get_status($fp); if($CheckStatus["unread_bytes"] == 0) {$do = 0;} } fclose($fp); $HLServerStats = explode("\\", $HLServerStats); $count = count($HLServerStats); if($count % 2 == 0) { $i = 0; while($count != $i) { $ServerData[$HLServerStats[$i]] = $HLServerStats[$i+1]; $i = $i + 2; } } echo($ServerData["address"]."\n<br>"); The problem I am having is that no connection is being made to the server. I know the server is up, and accepting requests, but it does not seem to work. What I do know is that the connection times out after the 10 second timeout I specify. My reference for this is: http://collective.valve-erc.com/index.php?doc=1063146620-20111500 Quote Link to comment https://forums.phpfreaks.com/topic/51535-connecting-with-udp/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.