Close socket for output and terminate connection, any attempt to write anything to it after
that will yield to IOException
498261
private void stopOut() throws IOException {
    if (outClosed) {
      return;
    }
    outClosed = true;

    LOG.log(Level.FINE, "Shutting down socket for output");

    // close socket for output - that will initiate normal socket close procedure; in case of TCP
    // socket this is
    // a buffer flush and TCP termination
    socket.shutdownOutput();
  }
359994
@Override
	public void close() throws IOException {
		boolean enqueueOnSocketClose;
		synchronized(closeLock) {
			if(closeTime == null) {
				// Remove this from the context
				socketContext.onClose(this);
				closeTime = System.currentTimeMillis();
				enqueueOnSocketClose = true;
			} else {
				enqueueOnSocketClose = false;
			}
		}
		if(enqueueOnSocketClose) {
			Future<?> future = listenerManager.enqueueEvent(
				new ConcurrentListenerManager.Event<SocketListener>() {
					@Override
					public Runnable createCall(final SocketListener listener) {
						return new Runnable() {
							@Override
							public void run() {
								listener.onSocketClose(AbstractSocket.this);
							}
						};
					}
				}
			);
			try {
				logger.log(Level.FINE, "Waiting for calls to onSocketClose to complete");
				future.get();
				logger.log(Level.FINE, "All calls to onSocketClose finished");
			} catch(ExecutionException e) {
				logger.log(Level.SEVERE, null, e);
			} catch(InterruptedException e) {
				logger.log(Level.SEVERE, null, e);
				// Restore the interrupted status
				Thread.currentThread().interrupt();
			}
		}
		listenerManager.close();
	}
1172122
def exit(self, result=0, msg=None, *args, **kwargs):
    """"""
    if self._finalizer:
      try:
        self._finalizer()
      except Exception as e:
        try:
          NailgunProtocol.send_stderr(
            self._socket,
            '\nUnexpected exception in finalizer: {!r}\n'.format(e)
          )
        except Exception:
          pass

    try:
      # Write a final message to stderr if present.
      if msg:
        NailgunProtocol.send_stderr(self._socket, msg)

      # Send an Exit chunk with the result.
      NailgunProtocol.send_exit_with_code(self._socket, result)

      # Shutdown the connected socket.
      teardown_socket(self._socket)
    finally:
      super(DaemonExiter, self).exit(result=result, *args, **kwargs)
549081
public void close()
    throws IOException
  {
    ServerSocket ss = _ss;
    _ss = ss;

    if (ss != null) {
      try {
        ss.close();
      } catch (Exception e) {
      }
    }
  }
543894
def socket_reader(connection: socket, buffer_size: int = 1024):
    
    while connection is not None:
        try:
            buffer = connection.recv(buffer_size)
            # no output
            if not len(buffer):
                raise ConnectionAbortedError
        except ConnectionAbortedError:
            # socket closed
            print('connection aborted')
            connection.close()
            yield None
        except OSError:
            # still operate connection after it was closed
            print('socket closed')
            connection.close()
            yield None
        else:
            yield buffer
614460
@Override
  public void closeWrite() throws IOException
  {
    if (_isCloseWrite) {
      return;
    }
    
    _isCloseWrite = true;
    
    //OutputStream os = _os;
    //_os = null;
    
    boolean isShutdownOutput = false;

    // since the output stream is opened lazily, we might
    // need to open it
    if (_s != null) {
      try {
        _s.shutdownOutput();
        
        isShutdownOutput = true;
      } catch (UnsupportedOperationException e) {
        log.log(Level.FINEST, e.toString(), e);
      } catch (Exception e) {
        log.finer(e.toString());
        log.log(Level.FINEST, e.toString(), e);
      }
    }

    /*
    // SSLSocket doesn't support shutdownOutput()
    if (! isShutdownOutput && os != null) {
      os.close();
    }
    */
  }
516070
void closeWriter() throws IOException {
    checkState(isRunning(), "Cannot read items from a %s StreamService", state());
    checkState(socketWriter != null, "Attempted to close the socket before it was opened.");
    try {
      socketWriter.close();
    } catch (IOException e) {
      notifyFailed(e);
      throw e;
    }
    closeStream();
  }
887254
@Override
  public void close()
    throws IOException
  {
    SocketChannel s = _channel;
    _channel = null;
    
    SSLSocket sslSocket = _sslSocket;
    _sslSocket = null;

    if (sslSocket != null) {
      try {
        sslSocket.close();
      } catch (Exception e) {
      }
    }

    if (s != null) {
      try {
        s.close();
      } catch (Exception e) {
      }
    }
  }
1344213
def close_socket(self):
        ''''''
        log.debug("Closing socket")
        if self.sock:
            try:
                self.sock.close()
            except:
                pass

            self.sock = None
1311417
@Override
  public void close() throws IOException
  {
    Socket s = _s;
    _s = null;

    OutputStream os = _os;
    _os = null;

    InputStream is = _is;
    _is = null;

    try {
      if (os != null)
        os.close();
      
      if (is != null)
        is.close();
    } finally {
      if (s != null)
        s.close();
    }
  }
203984
def _close_socket(self):
        
        try:
            self.socket.shutdown(socket.SHUT_RDWR)
        except (OSError, socket.error):
            pass
        self.socket.close()
1281378
public void close()
        throws IOException
    {
        if (server != null) {
            OutputStream os = getOutputStream();
            this.os = null;

            MuxServer server = this.server;
            this.server = null;

            server.close(channel);
        }
    }
1200369
private void stopIn() throws IOException {
    if (inClosed) {
      return;
    }
    inClosed = true;

    LOG.log(Level.FINE, "Shutting down socket for input");

    // unblock all waiting readers
    setEof();

    // signal orchestrator thread it is ok to quit now as there will be no more input
    synchronized (orchestratorEvent) {
      shutdown = true;
      orchestratorEvent.notifyAll();
    }

    // close socket for input - that will cause readExecutor to throw EOFException
    // and exit orchestrator thread main loop; client can still write to the socket
    socket.shutdownInput();
  }
120701
def close(self):
        
        log.debug("Closing socket connection for %s:%d" % (self.host, self.port))
        if self._sock:
            # Call shutdown to be a good TCP client
            # But expect an error if the socket has already been
            # closed by the server
            try:
                self._sock.shutdown(socket.SHUT_RDWR)
            except socket.error:
                pass

            # Closing the socket should always succeed
            self._sock.close()
            self._sock = None
        else:
            log.debug("No socket found to close!")
824549
public void close() {
        if (connected) {
            try {
                transport.close();
                socket.close();
            }
            catch (IOException ex) {
                logger.warn("Could not close socket", ex);
            }
            connected = false;
        }
    }
1126501
def _close_connection(self):
        """"""
        if (self._mode == PROP_MODE_SERIAL):
            self._serial.close()
        elif (self._mode == PROP_MODE_TCP):
            self._socket.close()
        elif (self._mode == PROP_MODE_FILE):
            self._file.close()
175237
void close() {
        try {
            performTeardownExchange();
        } catch (IOException e) {
            logger.warn("Problem reporting our intention to close the dbserver connection", e);
        }
        try {
            channel.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client output channel", e);
        }
        try {
            os.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client output stream", e);
        }
        try {
            is.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client input stream", e);
        }
        try {
            socket.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client socket", e);
        }
    }