Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts

    Gameserver Tracking

    Im trying to get contact with gameservers using the fopensock() command, but in order to contact gameservers the ip address prefix needs to start with udp://ipaddress. But the problem im having is it always thinks the inputted ip address is always true although i've tried having an ip address which does not represent anything and it still thinks it is online.

    heres my code :


    PHP Code:
    <?
    $ip 
    "195.8.208.32";
    $port "27015";
    $fp=pfsockopen("udp://".$ip.""$port$num$error5);
    if (!
    $fp){
    echo 
    '<B><FONT COLOR=red>Offline</b></FONT>';
    }else{
    echo 
    '<B><FONT COLOR=lime>Online</b></FONT>';
    fclose($fp);
    }

    ?>
    so whatever i put in the ip address i put in it displays Online.

    Anyone know the issue here?

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    PErhaps useful info from the man page:
    Warning

    UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data.
    Are you a Help Vampire?

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    So what can i do to make it recieve data?

    fget command? or something similar?

  • #4
    New Coder
    Join Date
    Jan 2009
    Posts
    91
    Thanks
    17
    Thanked 1 Time in 1 Post
    Could ping it. Once every so many minutes.

  • #5
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by Killermud View Post
    So what can i do to make it recieve data?

    fget command? or something similar?
    Don't know. Never used it. But I can read the man page, and from the examples and comments, that looks right. Maybe fgets() or fread()?
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •