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

Socket connections

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi, I'm having a little trouble with Socket's!
public boolean isConnected(String ipAddress)
{
final int dayTimePort = 13;
final int pingPort = 7003;
final int telnetPort = 23;
BufferedReader in = null;
Socket socketComputer = null;
try
{
socketComputer = new Socket(ipAddress, dayTimePort);
//in = new BufferedReader(new InputStreamReader(socketComputer.getInputStream()));
//String timeStamp = in.readLine();
return true;
}
catch(UnknownHostException e)
{
return false;
}
catch(IOException e)
{
return false;
}
}
This is used to check whether any of our critical systems have gone down, the boolean returned is used to determine what image and set of actions to do/display on the intranet site I'm developing.
The above code works fine, however testing it by giving it a fake ipaddress, i.e. one that doesn't exists( to act as a 'down' system) - the socket connection takes ages to conclude that it can't make a connection. This causes trouble by causing the page to display very very slowly.
Can anyone think of a way of improving this?
Any help would be very much appreciated!
Rowan.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This question has been answered in Sockets and Internet Protocols. Please do not post a question in more than one forum.
- Peter
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic