code: private void socketWrite(byte b[], int off, int len) throws IOException {
  
          if (len <= 0 || off < 0 || off + len > b.length) {
              if (len == 0) {
                  return;
              }
              throw new ArrayIndexOutOfBoundsException();
          }
  
          Object traceContext = IoTrace.socketWriteBegin();
          int bytesWritten = 0;
          FileDescriptor fd = impl.acquireFD();
          try {
              BlockGuard.getThreadPolicy().onNetwork();
              socketWrite0(fd, b, off, len);
              bytesWritten = len;
          } catch (SocketException se) {
              if (se instanceof sun.net.ConnectionResetException) {
                  impl.setConnectionResetPending();
                  se = new SocketException("Connection reset");
              }
              if (impl.isClosedOrPending()) {
                  throw new SocketException("Socket closed");
              } else {
                  throw se;
              }
          } finally {
              IoTrace.socketWriteEnd(traceContext, impl.address, impl.port, bytesWritten);
          }
      }
docs: Writes to the socket with appropriate locking of the
  FileDescriptor.
  @param b the data to be written
  @param off the start offset in the data
  @param len the number of bytes that are written
  @exception IOException If an I/O error has occurred.