| | |
java ping
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 159
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 |
Tag cloud for Java
addressbook android api apple applet application arguments array arrays automation awt binary bluetooth button calculator chat class classes client code columns component converter database draw eclipse error errors event exception file fractal ftp game givemetehcodez graphics gridlayout gui helpwithhomework html ide image inetaddress input integer invokingapacheantprogrammatically j2me java javaprojects jme jmf jni jpanel julia link linux list loop map method methods midlethttpconnection mobile netbeans newbie number objects openjavafx oracle php print problem program programming project projects recursion rim scanner screen server set signing size smart sms socket sort sql storm string support swing test threads time tree variablebinding webservices windows





