|
-
Jan 28th, 2010, 07:38 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Checking is IP Online?
I would like to create check online status for gameserver so is there any kind of way to do that?
-
Jan 28th, 2010, 08:46 AM
#2
Re: Checking is IP Online?
If you know which port the gameserver is running on, you could use fsockopen to check whether it is up or not.
-
Jan 28th, 2010, 09:53 AM
#3
Thread Starter
Hyperactive Member
Re: Checking is IP Online?
I already used this, but i don't get right answer.
(Let's play that mysql is my gameserver now.)
PHP Code:
<?php
$Get = fsockopen("127.0.0.1", "3306", $ErrorNo, $ErrorSTR, 5);
if($Get) {
echo "Online";
}
else {
echo "Offline";
}
?>
MySQL as turned off.
Warning: fsockopen() [function.fsockopen]: unable to connect to 127.0.0.1:3306 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\AppServ\www\index.php on line 9
Offline
MySQL as turned on.
How do i can filter this: "Warning" message from offline mode to only "Offline".
Still using same code. Just took MySQL for example.
-
Jan 28th, 2010, 09:57 AM
#4
Re: Checking is IP Online?
-
Jan 28th, 2010, 09:59 AM
#5
Thread Starter
Hyperactive Member
Re: Checking is IP Online?
 Originally Posted by kows
Thank you this helped.
Didn't knew any keywords of this and it didn't came to my mind.
-
Jan 28th, 2010, 10:57 AM
#6
Fanatic Member
Re: [RESOLVED] Checking is IP Online?
hey Zeuz this code doesn't show the errors if the warnings are on... by the way, the warnings are good to have on.
Code:
<?php
$host = "192.168.1.15"; // ip or domain
$port = "80";
@$socket = fsockopen($host, $port, $errno, $errstr, 5);
if(!$socket) {
echo "Offline";
} else {
fclose($socket);
echo "Online";
}
?>
-
Jan 28th, 2010, 11:10 AM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED] Checking is IP Online?
Oh. I try this later Justa.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|