本文整理匯總了Java中java.net.Socket.isOutputShutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java Socket.isOutputShutdown方法的具體用法?Java Socket.isOutputShutdown怎麽用?Java Socket.isOutputShutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.Socket
的用法示例。
在下文中一共展示了Socket.isOutputShutdown方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: closeSocketOutput
import java.net.Socket; //導入方法依賴的package包/類
private void closeSocketOutput(Socket socket) {
try {
if (!socket.isOutputShutdown()) {
socket.shutdownOutput();
}
} catch (IOException e) {
LOG.warn("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage());
}
}
示例3: shutdownOutput
import java.net.Socket; //導入方法依賴的package包/類
private static void shutdownOutput(Socket socket) {
if (socket != null && !socket.isOutputShutdown()) {
try {
LoggerFactory.getLogger().info("關閉Socket輸出...");
socket.shutdownOutput();
} catch (IOException e) {
LoggerFactory.getLogger().error("關閉Socket輸出異常", e);
}
}
}