Java Socket Check isSocketTimeoutException(final InterruptedIOException e)

Here you can find the source of isSocketTimeoutException(final InterruptedIOException e)

Description

If SocketTimeoutExceptionClass is defined, returns true only if the exception is an instance of SocketTimeoutExceptionClass.

License

Apache License

Parameter

Parameter Description
e an instance of InterruptedIOException class.

Return

true if the exception signals socket timeout, false otherwise.

Declaration

public static boolean isSocketTimeoutException(final InterruptedIOException e) 

Method Source Code


//package com.java2s;
/*//from   w  ww.  j  a v a 2  s . c o  m
 * $Header:
 * /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons
 * //httpclient/src/java/org/apache/commons/httpclient/util/ExceptionUtil.java,v
 * 1.5 2004/10/19 18:09:46 olegk Exp $ $Revision: 480424 $ $Date: 2006-11-29
 * 06:56:49 +0100 (Wed, 29 Nov 2006) $
 *
 * ====================================================================
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with this
 * work for additional information regarding copyright ownership. The ASF
 * licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many individuals on
 * behalf of the Apache Software Foundation. For more information on the Apache
 * Software Foundation, please see <http://www.apache.org/>.
 */

import java.io.InterruptedIOException;

import java.net.SocketTimeoutException;

public class Main {
    /**
     * If SocketTimeoutExceptionClass is defined, returns <tt>true</tt> only if
     * the exception is an instance of SocketTimeoutExceptionClass. If
     * SocketTimeoutExceptionClass is undefined, always returns <tt>true</tt>.
     *
     * @param e
     *        an instance of InterruptedIOException class.
     *
     * @return <tt>true</tt> if the exception signals socket timeout,
     *         <tt>false</tt> otherwise.
     */
    public static boolean isSocketTimeoutException(final InterruptedIOException e) {
        return e instanceof SocketTimeoutException;
    }
}

Related

  1. isConnected(Socket socket)
  2. isSocketClosed(SocketException e)
  3. isSocketReadyToWrite(Socket socket)