Class NoRouteToHostException in Java

Share and Enjoy !

Class NoRouteToHostException in Java

A NoRouteToHostException is thrown when a socket connection cannot be established with a remote host. This type of exception usually indicates that a firewall is blocking access to the host, or that an intermediate router is down.

An application can throw this -NoRouteToHostException exception to indicate a socket could not be connected with the remote host, as the host could not be connected due to one of the following reasons:

  • A host could not be connected before establishing the socket
  • Some intermediate link/links between local machine to host is/are down.
  • A host may be behind a firewall.

This exception-NoRouteToHostException is a subclass of SocketException and is common exception classes in java.

The structure of NoRouteToHostException is given as:

public class extends{
public NoRouteToHostException();//default constrcutor this constructor creates a NoRouteToHostException with no associated detail message
public NoRouteToHostException(String message);//This constructor creates a NoRouteToHostException with the specified detail message.

The class NoRouteToHostException also inherits methods from class Object and Throwable.

From Object classFrom Throwable class
wait(long, int)getLocalizedMessage()

Share and Enjoy !

READ  Class System in Java

Leave a Reply

Your email address will not be published. Required fields are marked *