Class NoRouteToHostException in Java

digitization, transformation, binary

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:

Ads code goes here
  • 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 java.net.NoRouteToHostException extends java.io.SocketException{
//constrcutors:
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
clone()fillInStackTrace()
getClass()getMessage()
notify()printStackTrace()
wait()printStackTrace(PrintWriter)
wait(long, int)getLocalizedMessage()
wait(long)printStackTrace(PrintStream)
equals(Object)
toString()
finalize()
hashCode()
notifyAll()

Share and Enjoy !

READ  Learn Methods in Java in a Quick Manner

Leave a Comment

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