code: @Override
    public void write(Buffer buffer, boolean isEnd)
      throws IOException
    {
      if (_s == null) {
        buffer.free();
        return;
      }
      
      try {
        _needsFlush = true;
        
        if (buffer.isDirect()) {
          _totalWriteBytes += buffer.length(); 
          _s.write(buffer.direct());
          return;
        }
        
        _totalWriteBytes += buffer.length();
        
        while (buffer.length() > 0) {
          _writeBuffer.clear();
          
          buffer.read(_writeBuffer);
          _writeBuffer.flip();
          
          _s.write(_writeBuffer);
        }
      } catch (IOException e) {
        IOException exn = ClientDisconnectException.create(this + ":" + e, e);
        
        try {
          close();
        } catch (IOException e1) {
        }
  
        throw exn;
      } finally {
        buffer.free();
      }
    }
docs: Writes an nio buffer to the socket.