Computing.Net > Forums > Web Development > Know if IP is online, with PHP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Know if IP is online, with PHP

Reply to Message Icon

Name: cernov
Date: July 29, 2006 at 21:31:56 Pacific
OS: Apache
CPU/Ram: Semprom
Product: AMD
Comment:

Can I know, using PHP (and ping, i think), if a ip is online in the internet?

Is there a script for it?

Thx



Sponsored Link
Ads by Google

Response Number 1
Name: smbotans
Date: July 30, 2006 at 20:06:32 Pacific
Reply:

what are you trying to do? monitor if your site is online? see if someone else is online?

serge

SEO Resources

Target the right Keywords

FREE SEO Report


0

Response Number 2
Name: Michael J (by mjdamato)
Date: July 31, 2006 at 12:35:53 Pacific
Reply:

The answer is yes and no. If you can't ping an IP it doesn't necessarily mean there is no device at that IP. Pinging can be blocked under certain circumstances - usually for security reasons.

Also, your terminology is a little incorrect which is confusing the issue (which is the reason for the previous respondent's questions). An IP is not online - a device can be on a network and will have an IP when it does. That IP can be public (internet) or private (internal LAN).

So, assuming there is a computer at a specific IP that you know you can ping, then the answer to your question is yes. Here is one solution: PHP Ping

Michael J


0

Response Number 3
Name: cernov
Date: August 5, 2006 at 12:39:10 Pacific
Reply:

Is there any script that ping a desired IP automatically?

Thanks


0

Response Number 4
Name: Michael J (by mjdamato)
Date: August 5, 2006 at 19:11:21 Pacific
Reply:

Define "automatically". Are you wanting to ping based upon a certain event or trigger. Or, are you wanting to have a ping based on a specified time interval?

If it is based upon an even, it will depend upon the event as to whether it can be done and how. If it is based upon time you could set up a scheduled task on the server.

Why don't you just tell us what it is you are trying to accomplish. There could be a very simple solution.
Michael J


0

Response Number 5
Name: cernov
Date: August 7, 2006 at 14:57:25 Pacific
Reply:

Sorry... my english is very bad :(
ehehe

I want some like this:

$x = ping("123.123.123.123");
if ($x) echo "the ip is connected";


0

Related Posts

See More



Response Number 6
Name: craigc
Date: August 30, 2006 at 16:24:17 Pacific
Reply:

Yeah, it can be done. I suggest you write your own script since everything out there seems to suck (post it on planetsourcecode for the rest of us).

I'm building a similar app at work right now, sorry can't share the code. I can point you in a good direction though.

Using PHP you can execute shell commands in a variety of ways such as (`ping 127.0.0.1` - backticks, eval(), escape(), and more).

The response you retrieve will will be specific to the ping application for the machine you are using.

You can do a $response = `ping 127.0.0.1 -c 1`; - or a similar command to suck in the response. From there you can parse the hell out of the input to get what you want (msecs, packet loss, etc).

Hint: Unknown hosts usually give you no response (On all OS's I have tried) - which is ok since everything else does. Three types of hosts (Unknown, Reachable, Unreachable). You will get a response time with reachable hosts and no response time with unreachable (Assuming your only going to ping it once at a given interval).


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Know if IP is online, with PHP

Connectors versus APIs ? www.computing.net/answers/webdevel/connectors-versus-apis-/1387.html

How To Track people With IP Address www.computing.net/answers/webdevel/how-to-track-people-with-ip-address/2308.html

Need help with PHP script (form) www.computing.net/answers/webdevel/need-help-with-php-script-form/2636.html