Skip to content

Common Java Networking Exceptions

by Vaibhav Aggarwal on December 28th, 2012
Exception Explanation
BindException Signals that an error occurred while attempting to bind a socket to a local address and port. Typically, the port is in use, or the requested local address could not be assigned.
ClosedChannelException Checked exception thrown when an attempt is made to invoke or complete an I/O operation upon channel that is closed, or at least closed to that operation. That this exception is thrown does not necessarily imply that the channel is completely closed. A socket channel whose write half has been shut down, for example, may still be open for reading.
ConnectException Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port) or connection timed out.
InterruptedIOException Signals that an I/O operation has been interrupted. An InterruptedIOException is thrown to indicate that an input or output transfer has been terminated because the thread performing it was interrupted. The field bytesTransferred indicates how many bytes were successfully transferred before the interruption occurred.
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 an intervening firewall, or if an intermediate router is down.
PortUnreachableException Signals that an ICMP Port Unreachable message has been received on a connected datagram.
ProtocolException Thrown to indicate that there is an error in the underlying protocol, such as a TCP error.
SocketException Thrown to indicate that there is an error in the underlying protocol, such as a TCP error.
SocketTimeoutException Signals that a timeout has occurred on a socket read or accept.
SSLException Indicates some kind of error detected by an SSL subsystem. This class is the general class of exceptions produced by failed SSL-related operations.
UnknownHostException Thrown to indicate that the IP address of a host could not be determined.
UnknownServiceException Thrown to indicate that an unknown service exception has occurred. Either the MIME type returned by a URL connection does not make sense, or the application is attempting to write to a read-only URL connection.

 

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS