當前位置: 首頁>>代碼示例>>Java>>正文


Java Socket.isOutputShutdown方法代碼示例

本文整理匯總了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;
}
 
開發者ID:pCloud,項目名稱:pcloud-networking-java,代碼行數:39,代碼來源:RealConnection.java

示例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());
    }
}
 
開發者ID:Achenglove,項目名稱:AndroidVideoCache,代碼行數:10,代碼來源:HttpProxyCacheServer.java

示例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);
        }
    }
}
 
開發者ID:spacetimeme,項目名稱:DreamSocket,代碼行數:11,代碼來源:DreamTCPSocket.java


注:本文中的java.net.Socket.isOutputShutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。