Jump to content

Recommended Posts

Hi, I have made a small script to obtain data from a call of duty game server and display it on a browser. Everything is working fine in my localhost server (Wamp Server 2.2).

When I move the script to my host in bluehost.com it doesn't return any error but doesn't return an output either. I can't find out why. I am not sure if the problem is in the code, please take a look at it.

 

<?php

$connect = fsockopen( "udp://" . "85.236.102.73", "28960", $errno, $errstr, 30 );
if( ! $connect ) exit( 'fsockopen did not connect' );

socket_set_timeout( $connect, 1, 0 );

$send = "\xFF\xFF\xFF\xFFgetstatus\x00";

fwrite( $connect, $send );
fputs( $connect, $send );

$output = fread( $connect, 5000 );

if( ! empty( $output ) ) {
  do {
        $status_pre = socket_get_status( $connect );
        $output = $output . fread( $connect, 5000 );
        $status_post = socket_get_status( $connect );
  }
  while( $status_pre['unread_bytes'] != $status_post['unread_bytes'] );
}
fclose( $connect );

echo $output;

?>

 

$errno returns 0 and $errstr returns nothing. I ran a fsockopen test i found on google, it was supposed to show bbc.com website title and it did so fsockopen is working. It wasn't an udp connection though so I am not sure if it is the problem. Could it be my host? What can I do?

 

$output is supposed to return something like this: ����statusResponse \_Admin\mh170085admin\_Email\clanservers@multiplay.co.uk\_GV_strea...

 

Please help, thanks.

Why are you calling fwrite () twice? I suspect this might be the cause of your problems.

Tested the (correct) code myself, and it worked for me:

$c = fsockopen ("udp://85.236.102.73", 28960, $errno, $errstr, 30);
if (!$c) {
    die ($errno.": ".$errstr);
}

socket_set_timeout ($c, 1000);
$send = "\xFF\xFF\xFF\xFFgetstatus\x00";

fwrite ($c, $send);
$output = fread ($c, 5000);

var_dump ($output);
// string(529) "����statusResponse\_Admin\mh170085admin\_Email\clanservers@multiplay.co.uk\_GV_streaming\enabled - CB v7.2\_Location\London, UK\_Website\http://www.multiplay.co.uk\fs_game\main\g_antilag\0\g_gametype\sd\g_needpass\1\gamename\Call of Duty 2\mapname\mp_dawnville\protocol\118\scr_friendlyfire\1\scr_killcam\0\shortversion\1.3\sv_allowAnonymous\0\sv_floodProtect\1\sv_hostname\Multiplay :: SCWTIRFLT\sv_maxclients\10\sv_maxPing\0\sv_maxRate\25000\sv_minPing\0\sv_privateClients\0\sv_punkbuster\1\sv_pure\1\sv_voice\0\pswrd\1\mod\1"

Again that script works on localhost but not on my Bluehost.com host.

This time it seems to enter a loop, the page loading animation doesn't disappear and nothing is shown on the page.

 

Edit: I fixed the loading *problem* with socket_set_timeout( $c, 1, 0 );

Now all it returns is: string(0) ""

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.