Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[PHP] Pinging

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Localhost
I post too much
Reputation: 0

Joined: 28 Apr 2007
Posts: 3402

PostPosted: Mon May 19, 2008 1:22 pm    Post subject: [PHP] Pinging Reply with quote

Hey, i want to make a script like

if ping www.website.com:8080 (true)
echo ¨IRC Server Up¨;
else ping www.website.com:8080 (false)
echo ¨IRC Server Down¨;

I know this wont work... Any other ways to check if a server is alive?
Back to top
View user's profile Send private message MSN Messenger
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon May 19, 2008 2:05 pm    Post subject: Reply with quote

There is no ping function.
There is just some kind of connection function which will return false on timeout. There are alot scripts around
Example:
http://www.php-free.de/Detailed/1088.html
Back to top
View user's profile Send private message
faenix
Newbie cheater
Reputation: 0

Joined: 17 Sep 2007
Posts: 20

PostPosted: Mon May 19, 2008 2:34 pm    Post subject: Reply with quote

Why not just use PEAR Net_Ping

http://pear.php.net/package/Net_Ping

Usage: http://pear.php.net/manual/en/package.networking.net-ping.php
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Mon May 19, 2008 3:12 pm    Post subject: Reply with quote

Code:
<?php

   $status = fsockopen( "www.cheatengine.org", 80, 0, 0, 50 );
   
   if ( !$status ) {
       echo "Server down!\n";
   } else {
       echo "Server up!\n";
   }

   fclose( $status );

?>


Something like that?
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Mon May 19, 2008 7:51 pm    Post subject: Reply with quote

Avoiding the use of fsockopen, you can use normal sockets. I wrote this for my L2J server a while back to determine if the login server and game server were online. Heres a modded version for websites:

Code:
<?php

   $serverHost = "www.cheatengine.org";
   $serverPort = 80;

   function createSocket()
   {
      $socket = @socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
      @socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>10, "usec"=>100) );
      if( !$socket ){
         die( 'Failed to create a new socket.' );
      }else{
         return $socket;
      }
   }
   
   function CheckIfRunning()
   {
      global $serverHost, $serverPort;
      $socket = createSocket();
      $connection = @socket_connect( $socket, gethostbyname( $serverHost ), $serverPort );
      if( !$connection )
         echo( 'Server is not online.' );
      else
         echo( 'Server is online!' );
      @socket_close( $socket );
   }
?>

<HTML>
<HEAD>
 <TITLE>Server Check</TITLE>
</HEAD>
<BODY>
 <p> <?php CheckIfRunning(); ?> </p>
</BODY>
</HTML>

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites