java.net.Socket.shutdownOutput()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(266)

本文整理了Java中java.net.Socket.shutdownOutput()方法的一些代码示例,展示了Socket.shutdownOutput()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Socket.shutdownOutput()方法的具体详情如下:
包路径:java.net.Socket
类名称:Socket
方法名:shutdownOutput

Socket.shutdownOutput介绍

[英]Closes the output stream of this socket. All buffered data will be sent followed by the termination sequence. Writing to the closed output stream will cause an IOException.
[中]关闭此套接字的输出流。所有缓冲数据将在终止序列后发送。写入关闭的输出流将导致IOException。

代码示例

代码示例来源:origin: alibaba/canal

public void close() {
  Socket socket = this.socket;
  if (socket != null) {
    try {
      socket.shutdownInput();
    } catch (IOException e) {
      // Ignore, could not do anymore
    }
    try {
      socket.shutdownOutput();
    } catch (IOException e) {
      // Ignore, could not do anymore
    }
    try {
      socket.close();
    } catch (IOException e) {
      // Ignore, could not do anymore
    }
  }
  this.input = null;
  this.output = null;
  this.socket = null;
}

代码示例来源:origin: stackoverflow.com

public void gracefulDisconnect(Socket sok) {
  InputStream is = sok.getInputStream();
  sok.shutdownOutput(); // Sends the 'FIN' on the network
  while (is.read() >= 0) ; // "read()" returns '-1' when the 'FIN' is reached
  sok.close(); // Now we can close the Socket
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
protected void finalize() throws Throwable {
 try {
  if ( socket != null ) {
   socket.shutdownInput();
   socket.shutdownOutput();
   socket.close();
  }
 } catch ( java.io.IOException e ) {
  // Ignore errors
 } finally {
  super.finalize();
 }
}

代码示例来源:origin: shyiko/mysql-binlog-connector-java

@Override
  public void close() throws IOException {
    try {
      socket.shutdownInput(); // for socketInputStream.setEOF(true)
    } catch (Exception e) {
      // ignore
    }
    try {
      socket.shutdownOutput();
    } catch (Exception e) {
      // ignore
    }
    socket.close();
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
protected void finalize() throws Throwable {
 try {
  if ( socket != null ) {
   socket.shutdownInput();
   socket.shutdownOutput();
   socket.close();
  }
  if ( serverSocket != null ) {
   serverSocket.close();
  }
 } catch ( IOException e ) {
  // Ignore errors
 } finally {
  super.finalize();
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
protected void finalize() throws Throwable {
 try {
  if ( clientSocket != null ) {
   clientSocket.shutdownInput();
   clientSocket.shutdownOutput();
   clientSocket.close();
  }
  if ( serverSocket != null ) {
   serverSocket.close();
  }
 } catch ( java.io.IOException e ) {
  // Ignore errors
 } finally {
  super.finalize();
 }
}

代码示例来源:origin: jenkinsci/jenkins

o.write("Remoting-Minimum-Version: " + RemotingVersionInfo.getMinimumSupportedVersion() + "\r\n");
    o.flush();
    s.shutdownOutput();
  } else {
    o.write("HTTP/1.0 404 Not Found\r\n");
    o.write("Not Found\r\n");
    o.flush();
    s.shutdownOutput();
  s.shutdownInput();
} finally {
  s.close();

代码示例来源:origin: robovm/robovm

public void close() throws IOException {
  if (!this.open) {
    return;
  }
  this.open = false;
  doFlush();
  try {
    this.socket.shutdownOutput();
  } catch (IOException ignore) {
  }
  try {
    this.socket.shutdownInput();
  } catch (IOException ignore) {
  }
  this.socket.close();
}

代码示例来源:origin: robovm/robovm

public void close() throws IOException {
  if (!this.open) {
    return;
  }
  this.open = false;
  doFlush();
  try {
    try {
      this.socket.shutdownOutput();
    } catch (IOException ignore) {
    }
    try {
      this.socket.shutdownInput();
    } catch (IOException ignore) {
    }
  } catch (UnsupportedOperationException ignore) {
    // if one isn't supported, the other one isn't either
  }
  this.socket.close();
}

代码示例来源:origin: apache/zookeeper

sock.socket().shutdownOutput();
} catch (IOException e) {
  if (LOG.isDebugEnabled()) {
  sock.socket().close();
} catch (IOException e) {
  if (LOG.isDebugEnabled()) {

代码示例来源:origin: apache/zookeeper

sock.socket().shutdownOutput();
} catch (IOException e) {
  sock.socket().close();
} catch (IOException e) {
  if (LOG.isDebugEnabled()) {

代码示例来源:origin: pentaho/pentaho-kettle

public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {
 // Ignore errors, we don't care
 // If we are here, it means all work is done
 // It's a lot of work to keep it all in sync for now we don't need to do that.
 //
 try {
  data.inputStream.close();
 } catch ( Exception e ) {
  // Ignore nested exception
 }
 try {
  data.outputStream.close();
 } catch ( Exception e ) {
  // Ignore nested exception
 }
 try {
  data.socket.shutdownInput();
  data.socket.shutdownOutput();
  data.socket.close();
 } catch ( Exception e ) {
  // Ignore nested exception
 }
 super.dispose( smi, sdi );
}

代码示例来源:origin: apache/hbase

@Override
public synchronized void close() {
 disposeSasl();
 data = null;
 callCleanup = null;
 if (!channel.isOpen()) return;
 try {
  socket.shutdownOutput();
 } catch (Exception ignored) {
  if (SimpleRpcServer.LOG.isTraceEnabled()) {
   SimpleRpcServer.LOG.trace("Ignored exception", ignored);
  }
 }
 if (channel.isOpen()) {
  try {
   channel.close();
  } catch (Exception ignored) {
  }
 }
 try {
  socket.close();
 } catch (Exception ignored) {
  if (SimpleRpcServer.LOG.isTraceEnabled()) {
   SimpleRpcServer.LOG.trace("Ignored exception", ignored);
  }
 }
}

代码示例来源:origin: apache/zookeeper

sock.getOutputStream().write("isro".getBytes());
sock.getOutputStream().flush();
sock.shutdownOutput();
br = new BufferedReader(
    new InputStreamReader(sock.getInputStream()));
if (sock != null) {
  try {
    sock.close();
  } catch (IOException e) {
    LOG.warn("Unexpected exception", e);

代码示例来源:origin: apache/zookeeper

sock.shutdownOutput();
  throw new IOException("Exception while executing four letter word: " + cmd, e);
} finally {
  sock.close();
  if (reader != null) {
    reader.close();

代码示例来源:origin: org.apache.zookeeper/zookeeper

outstream.flush();
  sock.shutdownOutput();
  throw new IOException("Exception while executing four letter word: " + cmd, e);
} finally {
  sock.close();
  if (reader != null) {
    reader.close();

代码示例来源:origin: org.apache.zookeeper/zookeeper

sock.socket().shutdownOutput();
} catch (IOException e) {
  if (LOG.isDebugEnabled()) {
  sock.socket().close();
} catch (IOException e) {
  if (LOG.isDebugEnabled()) {

代码示例来源:origin: apache/nifi

public static void closeQuietly(final Socket socket) {
  if (socket == null) {
    return;
  }
  try {
    try {
      // can't shudown input/output individually with secure sockets
      if ((socket instanceof SSLSocket) == false) {
        if (socket.isInputShutdown() == false) {
          socket.shutdownInput();
        }
        if (socket.isOutputShutdown() == false) {
          socket.shutdownOutput();
        }
      }
    } finally {
      if (socket.isClosed() == false) {
        socket.close();
      }
    }
  } catch (final Exception ex) {
    logger.debug("Failed to close socket due to: " + ex, ex);
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

sock.socket().shutdownOutput();
} catch (IOException e) {
  sock.socket().close();
} catch (IOException e) {
  if (LOG.isDebugEnabled()) {

代码示例来源:origin: org.apache.zookeeper/zookeeper

sock.getOutputStream().write("isro".getBytes());
sock.getOutputStream().flush();
sock.shutdownOutput();
br = new BufferedReader(
    new InputStreamReader(sock.getInputStream()));
if (sock != null) {
  try {
    sock.close();
  } catch (IOException e) {
    LOG.warn("Unexpected exception", e);

相关文章

微信公众号

最新文章

更多