gnize Posted August 5, 2008 Share Posted August 5, 2008 Hello. Just wondering if someone could help me with this script. What it does it get the status of a game server. Status shows players names score etc. I'm running php version 5 (PHP version 5.2.6) and Apache version 1.3.41 (Unix) <?PHP $open = fsockopen("udp://xz.sytes.net", 28960); socket_set_timeout($open, 1); fwrite($open, "\xFF\xFF\xFF\xFFgetstatus"); $result = fread($open, 8192); echo $result; exit(); ?> Does my web host need to have that port open to recive the info? When I run the php file from a web browser it shows a blank page. Any help would be awesome. Please and thanks. Gnize.d Link to comment https://forums.phpfreaks.com/topic/118320-get-status-of-game-server/ Share on other sites More sharing options...
Third_Degree Posted August 5, 2008 Share Posted August 5, 2008 Your code looks a little haphazard. I don't exactly know which protocol or port for that matter you are using but try something more like this: <?php $open = @fsockopen( "xs.sytes.net", 28960, $no, $str, 5 ) or die( 'Connection Failed' ); fwrite( $open, "\xFF\xFF\xFF\xFFgetstatus\r\n" ); print fread( $open, 8192 ); ?> Link to comment https://forums.phpfreaks.com/topic/118320-get-status-of-game-server/#findComment-608887 Share on other sites More sharing options...
gnize Posted August 5, 2008 Author Share Posted August 5, 2008 That helped a lot, thanks for the fast reply. If I'm getting connection failed, what do you think is the cause of that? Fsock being disabled? Or the port closed? Link to comment https://forums.phpfreaks.com/topic/118320-get-status-of-game-server/#findComment-608903 Share on other sites More sharing options...
Barand Posted August 5, 2008 Share Posted August 5, 2008 Check the error message Link to comment https://forums.phpfreaks.com/topic/118320-get-status-of-game-server/#findComment-609054 Share on other sites More sharing options...
Third_Degree Posted August 6, 2008 Share Posted August 6, 2008 I know Barand directed his post to gnize but I took the liberty of running the script and the error is a timeout. So A)The server is offline/does not exist or B)The port is not open on the server Link to comment https://forums.phpfreaks.com/topic/118320-get-status-of-game-server/#findComment-609324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.