{@inheritDoc}

@see jcifs.internal.smb2.ServerMessageBlock2#writeBytesWireFormat(byte[], int)
494359
@Override
    protected int writeBytesWireFormat ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(36, dst, dstIndex);
        SMBUtil.writeInt2(this.dialects.length, dst, dstIndex + 2);
        dstIndex += 4;

        SMBUtil.writeInt2(this.securityMode, dst, dstIndex);
        SMBUtil.writeInt2(0, dst, dstIndex + 2); // Reserved
        dstIndex += 4;

        SMBUtil.writeInt4(this.capabilities, dst, dstIndex);
        dstIndex += 4;

        System.arraycopy(this.clientGuid, 0, dst, dstIndex, 16);
        dstIndex += 16;

        // if SMB 3.11 support negotiateContextOffset/negotiateContextCount
        int negotitateContextOffsetOffset = 0;
        if ( this.negotiateContexts == null || this.negotiateContexts.length == 0 ) {
            SMBUtil.writeInt8(0, dst, dstIndex);
        }
        else {
            negotitateContextOffsetOffset = dstIndex;
            SMBUtil.writeInt2(this.negotiateContexts.length, dst, dstIndex + 4);
            SMBUtil.writeInt2(0, dst, dstIndex + 6);
        }
        dstIndex += 8;

        for ( int dialect : this.dialects ) {
            SMBUtil.writeInt2(dialect, dst, dstIndex);
            dstIndex += 2;
        }

        dstIndex += pad8(dstIndex);

        if ( this.negotiateContexts != null && this.negotiateContexts.length != 0 ) {
            SMBUtil.writeInt4(dstIndex - getHeaderStart(), dst, negotitateContextOffsetOffset);
            for ( NegotiateContextRequest nc : this.negotiateContexts ) {
                SMBUtil.writeInt2(nc.getContextType(), dst, dstIndex);
                int lenOffset = dstIndex + 2;
                dstIndex += 4;
                SMBUtil.writeInt4(0, dst, dstIndex);
                dstIndex += 4; // Reserved
                int dataLen = size8(nc.encode(dst, dstIndex));
                SMBUtil.writeInt2(dataLen, dst, lenOffset);
                dstIndex += dataLen;
            }
        }
        return dstIndex - start;
    }
1175799
public void writeBytes(byte header, byte[] bytes) {
    int length = bytes.length;
    while (remaining() < length + 10) {
      grow();
    }
    writeLength(length + 1);
    buf[position++] = header;
    System.arraycopy(bytes, 0, buf, position, length);
    position += length;
  }
398618
@Override
    protected int readBytesWireFormat ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int start = bufferIndex;
        int structureSize = SMBUtil.readInt2(buffer, bufferIndex);
        if ( structureSize != 60 ) {
            throw new SMBProtocolDecodingException("Expected structureSize = 60");
        }
        this.closeFlags = SMBUtil.readInt2(buffer, bufferIndex + 2);
        bufferIndex += 4;
        bufferIndex += 4; // Reserved
        this.creationTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.lastAccessTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.lastWriteTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.changeTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.allocationSize = SMBUtil.readInt8(buffer, bufferIndex);
        bufferIndex += 8;
        this.endOfFile = SMBUtil.readInt8(buffer, bufferIndex);
        bufferIndex += 8;
        this.fileAttributes = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;

        if ( log.isDebugEnabled() ) {
            log.debug(String.format("Closed %s (%s)", Hexdump.toHexString(this.fileId), this.fileName));
        }

        return bufferIndex - start;
    }
796853
public synchronized void write(byte[] b, int off, int len) throws IOException {
		dataOutputStream.write(b, off, len);
		dataOutputStream.flush();
	}
252017
public void writeBytes(byte[] buffer, int offset, int length)
        throws IOException
    {
        if (buffer == null) {
            if (SIZE < _offset + 16)
                flushBuffer();

            _buffer[_offset++] = (byte) 'N';
        }
        else {
            while (SIZE - _offset - 3 < length) {
                int sublen = SIZE - _offset - 3;

                if (sublen < 16) {
                    flushBuffer();

                    sublen = SIZE - _offset - 3;

                    if (length < sublen)
                        sublen = length;
                }

                _buffer[_offset++] = (byte) BC_BINARY_CHUNK;
                _buffer[_offset++] = (byte) (sublen >> 8);
                _buffer[_offset++] = (byte) sublen;

                System.arraycopy(buffer, offset, _buffer, _offset, sublen);
                _offset += sublen;

                length -= sublen;
                offset += sublen;

                flushBuffer();
            }

            if (SIZE < _offset + 16)
                flushBuffer();

            if (length <= BINARY_DIRECT_MAX) {
                _buffer[_offset++] = (byte) (BC_BINARY_DIRECT + length);
            }
            else if (length <= BINARY_SHORT_MAX) {
                _buffer[_offset++] = (byte) (BC_BINARY_SHORT + (length >> 8));
                _buffer[_offset++] = (byte) (length);
            }
            else {
                _buffer[_offset++] = (byte) 'B';
                _buffer[_offset++] = (byte) (length >> 8);
                _buffer[_offset++] = (byte) (length);
            }

            System.arraycopy(buffer, offset, _buffer, _offset, length);

            _offset += length;
        }
    }
333100
private void writeByte(int b)
    {
        int offset = myOffset;
        if (--offset < 0) {
            offset = growBuffer(offset);
        }
        // Using narrowing primitive conversion from int to byte
        myBuffer[offset] = (byte) b;
        myOffset = offset;
    }
83794
@Override
    protected int readBytesWireFormat ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int start = bufferIndex;
        int structureSize = SMBUtil.readInt2(buffer, bufferIndex);
        if ( structureSize == 9 ) {
            return this.readErrorResponse(buffer, bufferIndex);
        }
        else if ( structureSize != 17 ) {
            throw new SMBProtocolDecodingException("Expected structureSize = 17");
        }

        short dataOffset = buffer[ bufferIndex + 2 ];
        bufferIndex += 4;
        this.dataLength = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        this.dataRemaining = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        bufferIndex += 4; // Reserved2

        int dataStart = getHeaderStart() + dataOffset;

        if ( this.dataLength + this.outputBufferOffset > this.outputBuffer.length ) {
            throw new SMBProtocolDecodingException("Buffer to small for read response");
        }
        System.arraycopy(buffer, dataStart, this.outputBuffer, this.outputBufferOffset, this.dataLength);
        bufferIndex = Math.max(bufferIndex, dataStart + this.dataLength);
        return bufferIndex - start;
    }
1022924
@Override
    protected int writeBytesWireFormat ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(32, dst, dstIndex);
        SMBUtil.writeInt2(this.notifyFlags, dst, dstIndex + 2);
        dstIndex += 4;

        SMBUtil.writeInt4(this.outputBufferLength, dst, dstIndex);
        dstIndex += 4;

        System.arraycopy(this.fileId, 0, dst, dstIndex, 16);
        dstIndex += 16;

        SMBUtil.writeInt4(this.completionFilter, dst, dstIndex);
        dstIndex += 4;
        dstIndex += 4; // Reserved
        return dstIndex - start;
    }
500759
@Override
    protected int writeParameterWordsWireFormat ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(this.fid, dst, dstIndex);
        dstIndex += 2;
        SMBUtil.writeInt2(this.mode, dst, dstIndex);
        dstIndex += 2;
        SMBUtil.writeInt4(this.offset, dst, dstIndex);
        dstIndex += 4;
        return dstIndex - start;
    }
147000
public void write(byte[] b)
        throws IOException
    {
        ensureSpareCapacity(b.length);
        System.arraycopy(b,0,_buf,_pos,b.length);
        _pos+=b.length;
    }
1372447
@Override
	public void writeBytes(byte[] value, int offset, int length) throws JMSException
    {
        try
        {
            getOutput().write(value,offset,length);
        }
        catch (IOException e)
        {
            throw new FFMQException("Cannot write message body","IO_ERROR",e);
        }
    }
273986
public void write(byte[] value, int start, int len) throws IOException
  {
    this.output.write(value, start, len);
  }
739317
@Override
    protected int writeBytesWireFormat ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(9, dst, dstIndex);
        SMBUtil.writeInt2(this.treeFlags, dst, dstIndex + 2);
        dstIndex += 4;

        byte[] data = this.path.getBytes(StandardCharsets.UTF_16LE);
        int offsetOffset = dstIndex;
        SMBUtil.writeInt2(data.length, dst, dstIndex + 2);
        dstIndex += 4;
        SMBUtil.writeInt2(dstIndex - getHeaderStart(), dst, offsetOffset);

        System.arraycopy(data, 0, dst, dstIndex, data.length);
        dstIndex += data.length;
        return dstIndex - start;
    }
1309979
@Override
    public int decode ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int len = super.decode(buffer, bufferIndex);
        if ( this.byteCount == 0 ) {
            // otherwise hasMore may not be correctly set
            readBytesWireFormat(buffer, len + bufferIndex);
        }
        nextElement();
        return len;
    }
193094
public void writeRawMessageSetExtension(final int fieldNumber,
                                          final ByteString value)
                                          throws IOException {
    writeTag(WireFormat.MESSAGE_SET_ITEM, WireFormat.WIRETYPE_START_GROUP);
    writeUInt32(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber);
    writeBytes(WireFormat.MESSAGE_SET_MESSAGE, value);
    writeTag(WireFormat.MESSAGE_SET_ITEM, WireFormat.WIRETYPE_END_GROUP);
  }
523279
@Override
    public void write(byte[] bts, int st, int end) throws IOException {
        try {
            beforeWrite(end);
            out.write(bts, st, end);
            afterWrite(end);
        } catch (IOException e) {
            handleIOException(e);
        }
    }
476405
@Override
    protected int readBytesWireFormat ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int start = bufferIndex;
        int structureSize = SMBUtil.readInt2(buffer, bufferIndex);

        if ( structureSize != 9 ) {
            throw new SMBProtocolDecodingException("Expected structureSize = 9");
        }

        int bufferOffset = SMBUtil.readInt2(buffer, bufferIndex + 2) + getHeaderStart();
        bufferIndex += 4;
        int bufferLength = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;

        // bufferIndex = bufferOffset;

        List<FileEntry> infos = new ArrayList<>();
        do {
            FileBothDirectoryInfo cur = createFileInfo();
            if ( cur == null ) {
                break;
            }
            cur.decode(buffer, bufferIndex, bufferLength);
            infos.add(cur);
            int nextEntryOffset = cur.getNextEntryOffset();
            if ( nextEntryOffset > 0 ) {
                bufferIndex += nextEntryOffset;
            }
            else {
                break;
            }
        }
        while ( bufferIndex < bufferOffset + bufferLength );
        this.results = infos.toArray(new FileEntry[infos.size()]);
        return bufferIndex - start;
    }