| | |
java ping
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 154
Reputation:
Solved Threads: 0
I am trying to write a program that will monitor my routers and servers and notify me when they go down. I am looking for a way to ping the host and read the reply. The InetAddress.isReachable method is the only thing i could find but it uses the echo port which windows has it off by default. i am looking for something generic that i can use on diffrent platforms. Windows, Linux, Cisco OS.
Take a look at the Runtime class. You can use its exec method to run a ping and the resulting Process has methods to allow you to obtain the I/O/E streams. This allows you to interpret the results of your ping, but note that there are differences in the ping implementation in Windows and Linux (not sure about Cisco OS sorry).
Hope this gives you some direction,
darkagn
Hope this gives you some direction,
darkagn
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. Hello, mrjoli021
I hope the Sun description of Runtime class help you:
http://java.sun.com/j2se/1.4.2/docs/...g/Runtime.html
I hope the Sun description of Runtime class help you:
http://java.sun.com/j2se/1.4.2/docs/...g/Runtime.html
Last edited by Antenka; Dec 6th, 2008 at 3:45 pm.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
As an aside, if you want to limit people to only use one instance of your class in an application, you can do something like this:
The Runtime class does something similar in order to limit the number of instances of Runtime objects to one.
java Syntax (Toggle Plain Text)
public class myClass { private static myClass instance = null; private myClass() { // do something when creating the instance } public static myClass getInstance() { if( instance == null ) { instance = new myClass(); } return instance; } }
The Runtime class does something similar in order to limit the number of instances of Runtime objects to one.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. ![]() |
Similar Threads
- Java Programmer wanted (Software Development Job Offers)
- java.net.SocketException: Connection reset by peer: socket write error (Java)
- Vista: NO COMMANDS RECOGNIZED IN COMMAND PROMPT!!! (Windows Vista and Windows 7)
- ping is not successful. (Java)
- ping a host (JSP)
- JNDI/JDBC lookup problem with Sun Java Application Server 8.2 (Java)
- strange problems (Windows 95 / 98 / Me)
- PING - Internet Explorer 5.0+ (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: help with watch program
- Next Thread: Number checking & User Exceptions
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component converter database developmenthelp eclipse error fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html ide image input int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor





