In this phrase, we illustrate the series of exceptions you should attempt to catch when performing network operations. The first exception we try to catch is the UnknownHostException. This is a subclass of IOException and is thrown to indicate that the IP address of a host could not be determined. NoRouteToHostException and the ConnectException are subclasses of SocketException. NoRouteToHostException signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the remote host cannot be reached because of a problem with an intervening firewall or router. ConnectException is thrown if a connection is refused to the remote host. IOException is a more general purpose exception that can also be thrown from networking calls. The phrases throughout this chapter and Chapter 11, "Network Servers," do not include error handling. Catching these exceptions is what you would do in your Java applications that use networking functionality. |