wood burning stoves 2.0*
The moose likes Web Services and the fly likes Check whether remote server is accessible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Check whether remote server is accessible" Watch "Check whether remote server is accessible" New topic

Check whether remote server is accessible

Ronnie D'costa

Joined: Dec 05, 2008
Posts: 8
Hi All,

I am parsing a WSDL from a remote server. If I have access to that server, I can do it very comfortably.

How do I put a validation like whether that Server is accessible to me. I saw a few examples like the one listed below (where I try to check whether echo port is accessible)

try {
Socket t = new Socket("<servername>", 7);
DataInputStream dis = new DataInputStream(t.getInputStream());
PrintStream ps = new PrintStream(t.getOutputStream());
String str = dis.toString();
if (str.equals("Hello"))
System.out.println("Alive!") ;
System.out.println("Cannot Connect to Server");
} catch (Exception e) {

I want to throw an Error message if I am unable to read the file on remote server. Also do I need specify the complete path (along with filename) while checking for the accessibility.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Check whether remote server is accessible
Similar Threads
simple socket programming
How does web server locates the path
Address already used problem in Java Socket application
reading from TCP socket problem
Wanted: Minimal Web Server Example