Results 1 to 20 of 20
- 02-05-2009, 12:21 PM #1
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
Java program to ping remote machine using IP address..?
Dear Members,
I have to ping a remote machine, which is used as a server for my support project. If the server is down it takes more time to load the application. So i have to redirect to error page 'Support site is down for maintanence'. How to know the status of remote machine, whether it is up or down.
Please let me know the solutions for this issue.
Regards,
Prabhu.
- 02-05-2009, 04:41 PM #2
Look at InetAddress.isReachable(). This performs the ping function and returns true if the ping was successful.
- 02-06-2009, 07:42 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
It's reduces number of code lines, trying to use a process.
- 08-16-2010, 07:45 AM #4
Member
- Join Date
- Aug 2010
- Posts
- 3
- Rep Power
- 0
Hi I wants to ping a remote server. As i am behind the proxy i am not able to ping it .Is there any way to bind proxy with InetAddress. This is always giving False result.
My code snippet is:
InetAddress address = InetAddress.getByName("www.google.com");
boolean chkConnection = address.isReachable(1000);
Please help
Regards
Sourabh
- 08-16-2010, 06:11 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Behind what firewall your request is?
- 08-17-2010, 10:40 AM #6
Member
- Join Date
- Aug 2010
- Posts
- 3
- Rep Power
- 0
Hi
I am behind a proxy server for Vlan. I can't access the internet directly. I access via proxy setting.
- 08-17-2010, 10:41 AM #7
Member
- Join Date
- Aug 2010
- Posts
- 3
- Rep Power
- 0
Please help me in how to bind proxy with inetAddress.
- 08-17-2010, 11:25 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Actually you cannot do this through a proxy server. I'll explain why I ask that question from you.
To ping to the outside host from your LAN, it's required to ICMP protocol request complete. Proxies are not allowed that. If you are using MS Proxy then it's allowed only passe UDP and TCP. We can control those things within the proxy server as you wish at the time of build it.
- 08-17-2010, 11:26 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What I can suggest you is to add the request object to the trusted list.
- 10-08-2010, 07:13 AM #10
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
Hi Everybody, Im trying to use the InetAddress.isReachable(). but its not known in my JDK, it is showing me an error , isReachable() methode is not recognized.
Please tell me how to fix this, i really need the solution
- 10-11-2010, 01:29 PM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you instantiate the relevant address?
- 10-11-2010, 01:29 PM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
It's better, if you could show something over here that what you've done. So it's easy to comment on you.
- 10-12-2010, 08:35 AM #13
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
hi, thanks for replying me.. here is the example code:
the isReachable() methode not recognized in my code , i have tried many examples.. still the same problem.Java Code:import java.io.IOException; import java.net.InetAddress; public class IPTest { public static void main(String[] args) { try { InetAddress adr = InetAddress.getByName("10.252.11.112"); System.out.println("Host is reachable: "+adr.isReachable(3000)); }catch (IOException e) { e.printStackTrace(); } } }Last edited by Eranga; 10-13-2010 at 06:13 AM. Reason: code tags added
- 10-13-2010, 06:15 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Hi Biboo, please use code tags next time when you are posting code segments. Sometimes, not like in a small code segment, it's really hard to read unformated codes. It's a good practice, use them. :)
If you don't know how to do it, check my forum signature. You can find a relevant link for that.
- 10-13-2010, 06:36 AM #15
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Regarding your question, what you mean by method not recognized in your code? Can you elaborate it.
- 10-13-2010, 08:27 PM #16
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
hi Eranga,
when i generate the code it says that isReachable() is not reconized , it is like not existing in the library.
you got me now??
- 10-14-2010, 06:06 AM #17
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you import required packages?
import java.net.InetAddress;
- 10-14-2010, 07:05 PM #18
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
Of course i did :P
i just cant understand...
- 10-15-2010, 08:11 AM #19
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you post the complete error message that comes with when you compile the code.
- 11-22-2011, 03:58 PM #20
Member
- Join Date
- Oct 2011
- Posts
- 1
- Rep Power
- 0
Re: Java program to ping remote machine using IP address..?
hey every one there is only one mistake that the agr you give in getByName() is add not name
try this:-
import java.io.*;
import java.net.*;
public class NetScanner2
{
byte a[] = {10,17,1,(byte)136};
public NetScanner2()
{
try
{
System.out.println(InetAddress.getByAddress(a).isR eachable(10000));
}catch(Exception e)
{}
}
public static void main(String []args)
{
new NetScanner2();
}
}
Similar Threads
-
Ping in Java
By VeasMKII in forum New To JavaReplies: 7Last Post: 10-14-2012, 09:51 PM -
how to place a file in remote machine using simple java class
By aradhya in forum Advanced JavaReplies: 10Last Post: 02-28-2012, 08:44 PM -
How to write a JAVA program to mesure ping delay..?
By sacr83 in forum NetworkingReplies: 1Last Post: 02-15-2008, 04:07 PM -
Getting address of Local Machine
By Java Tip in forum Java TipReplies: 0Last Post: 11-24-2007, 07:38 PM -
how to load a file in remote machine
By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks