• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Check whether remote server is accessible

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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());
ps.println("Hello");
String str = dis.toString();
if (str.equals("Hello"))
System.out.println("Alive!") ;
else
System.out.println("Cannot Connect to Server");
t.close();
} catch (Exception e) {
e.printStackTrace();
}

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.

Cheers!!!
Ronnie
 
reply
    Bookmark Topic Watch Topic
  • New Topic