File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes NoRouteToHostException when the system starts with no network connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "NoRouteToHostException when the system starts with no network connection" Watch "NoRouteToHostException when the system starts with no network connection" New topic
Author

NoRouteToHostException when the system starts with no network connection

Gurumoorthy Doraiswamy
Greenhorn

Joined: Jan 15, 2013
Posts: 21
Hi,

We have UDP client which we run as windows service using Java service wrapper. My problem is when the system starts with no network connection and when the service starts automatically i receive the "NoRouteToHostException".

How to resolve this? we tried with Datagramsocket.setReuseAddress(true) but still no use. The Datagramsocket.isconnected() always return false.

Can anyone suggest how to resolve this.

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Can you catch the Exception and set up a loop with a timer to check for a connection - say - once a minute?

Bill
Gurumoorthy Doraiswamy
Greenhorn

Joined: Jan 15, 2013
Posts: 21
Many thanks for the update.

I have performed the same for now to fix the issue. But is there any option like checking the datagram connected state ... etc.,

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NoRouteToHostException when the system starts with no network connection