本文整理匯總了Java中java.net.Socket.isInputShutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java Socket.isInputShutdown方法的具體用法?Java Socket.isInputShutdown怎麽用?Java Socket.isInputShutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.Socket
的用法示例。
在下文中一共展示了Socket.isInputShutdown方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shutdownInput
import java.net.Socket; //導入方法依賴的package包/類
private static void shutdownInput(Socket socket) {
if (socket != null && !socket.isInputShutdown()) {
try {
LoggerFactory.getLogger().info("關閉Socket輸入...");
socket.shutdownInput();
} catch (IOException e) {
LoggerFactory.getLogger().error("關閉Socket輸入異常", e);
}
}
}
示例2: isHealthy
import java.net.Socket; //導入方法依賴的package包/類
boolean isHealthy(boolean doExtensiveChecks) {
if (!connected) {
return false;
}
Socket socket;
BufferedSource source;
synchronized (this) {
socket = this.socket;
source = this.source;
}
if (socket == null ||
source == null ||
socket.isClosed() ||
socket.isInputShutdown() ||
socket.isOutputShutdown()) {
return false;
}
if (doExtensiveChecks) {
try {
int readTimeout = socket.getSoTimeout();
try {
socket.setSoTimeout(1);
return !source.exhausted();
} finally {
socket.setSoTimeout(readTimeout);
}
} catch (SocketTimeoutException ignored) {
ignored.printStackTrace();
// Read timed out; socket is good.
} catch (IOException e) {
return false; // Couldn't read; socket is closed.
}
}
return true;
}