当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionResetException类代码示例

本文整理汇总了Java中sun.net.ConnectionResetException的典型用法代码示例。如果您正苦于以下问题:Java ConnectionResetException类的具体用法?Java ConnectionResetException怎么用?Java ConnectionResetException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionResetException类属于sun.net包,在下文中一共展示了ConnectionResetException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: available

import sun.net.ConnectionResetException; //导入依赖的package包/类
/**
 * Returns the number of bytes that can be read without blocking.
 */
protected synchronized int available() throws IOException {
    if (isClosedOrPending()) {
        throw new IOException("Stream closed.");
    }

    /*
     * If connection has been reset or shut down for input, then return 0
     * to indicate there are no buffered bytes.
     */
    if (isConnectionReset() || shut_rd) {
        return 0;
    }

    /*
     * If no bytes available and we were previously notified
     * of a connection reset then we move to the reset state.
     *
     * If are notified of a connection reset then check
     * again if there are bytes buffered on the socket.
     */
    int n = 0;
    try {
        n = socketAvailable();
        if (n == 0 && isConnectionResetPending()) {
            setConnectionReset();
        }
    } catch (ConnectionResetException exc1) {
        setConnectionResetPending();
        try {
            n = socketAvailable();
            if (n == 0) {
                setConnectionReset();
            }
        } catch (ConnectionResetException exc2) {
        }
    }
    return n;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:AbstractPlainSocketImpl.java

示例2: available

import sun.net.ConnectionResetException; //导入依赖的package包/类
/**
    * Returns the number of bytes that can be read without blocking.
    */
   protected synchronized int available() throws IOException {
if (isClosedOrPending()) {
           throw new IOException("Stream closed.");
}

/*
 * If connection has been reset then return 0 to indicate
 * there are no buffered bytes.
 */
if (isConnectionReset()) {
    return 0;
}

/*
 * If no bytes available and we were previously notified
 * of a connection reset then we move to the reset state.
 *
 * If are notified of a connection reset then check
 * again if there are bytes buffered on the socket. 
 */
int n = 0;
try { 
    n = socketAvailable();
    if (n == 0 && isConnectionResetPending()) {
        setConnectionReset();
    }
} catch (ConnectionResetException exc1) {
    setConnectionResetPending();
    try {
        n = socketAvailable();
	if (n == 0) {
	    setConnectionReset();
	}
    } catch (ConnectionResetException exc2) {
    }
}
return n;
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:42,代码来源:PlainSocketImpl.java

示例3: exceptionTest

import sun.net.ConnectionResetException; //导入依赖的package包/类
@Test
public void exceptionTest() {
    FixedThreadPool ftp = new FixedThreadPool(2);
    TaskFuture<Integer> sleeping = ftp.submit(new SleepingTask(1000));
    TaskFuture throwing = ftp.submit(new ExceptionTask());
    sleeping.get();
    throwing.get();
    ftp.stop();
    assertEquals(sleeping.getException(), null);
    assert(throwing.getException() instanceof ConnectionResetException);
}
 
开发者ID:cscenter,项目名称:hpcourse,代码行数:12,代码来源:FixedThreadPoolTest.java

示例4: available

import sun.net.ConnectionResetException; //导入依赖的package包/类
/**
 * Returns the number of bytes that can be read without blocking.
 */
protected synchronized int available() throws IOException {
    if (isClosedOrPending()) {
        throw new IOException("Stream closed.");
    }

    /*
     * If connection has been reset then return 0 to indicate
     * there are no buffered bytes.
     */
    if (isConnectionReset()) {
        return 0;
    }

    /*
     * If no bytes available and we were previously notified
     * of a connection reset then we move to the reset state.
     *
     * If are notified of a connection reset then check
     * again if there are bytes buffered on the socket.
     */
    int n = 0;
    try {
        n = socketAvailable();
        if (n == 0 && isConnectionResetPending()) {
            setConnectionReset();
        }
    } catch (ConnectionResetException exc1) {
        setConnectionResetPending();
        try {
            n = socketAvailable();
            if (n == 0) {
                setConnectionReset();
            }
        } catch (ConnectionResetException exc2) {
        }
    }
    return n;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:42,代码来源:AbstractPlainSocketImpl.java

示例5: run

import sun.net.ConnectionResetException; //导入依赖的package包/类
@Override
public void run() throws ConnectionResetException {
    throw new ConnectionResetException();
}
 
开发者ID:cscenter,项目名称:hpcourse,代码行数:5,代码来源:ExceptionTask.java


注:本文中的sun.net.ConnectionResetException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。