本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例5: run
import sun.net.ConnectionResetException; //导入依赖的package包/类
@Override
public void run() throws ConnectionResetException {
throw new ConnectionResetException();
}