Java Code Examples for java.net.Socket.isOutputShutdown()

The following are Jave code examples for showing how to use isOutputShutdown() of the java.net.Socket class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pcloud-networking-java   File: RealConnection.java   View Source Code Vote up 5 votes
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;
}
 
Example 2
Project: AndroidVideoCache   File: HttpProxyCacheServer.java   View Source Code Vote up 5 votes
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());
    }
}
 
Example 3
Project: DreamSocket   File: DreamTCPSocket.java   View Source Code Vote up 5 votes
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);
        }
    }
}