private void ReadNextPacket(int len) { inBuffer = inBufferRef.Target as byte[]; if (inBuffer == null || inBuffer.Length < len) { inBuffer = new byte[len]; } MySqlStream.ReadFully(baseStream, inBuffer, 0, len); }
// Read MySQL packet // since SSPI blobs data cannot be larger than ~12K, // handling just single packet is sufficient private byte[] ReadData() { byte[] buffer; MySqlStream.ReadFully(stream, packetHeader, 0, 4); int length = (int)(packetHeader[0] + (packetHeader[1] << 8) + (packetHeader[2] << 16)); seq = packetHeader[3] + 1; buffer = new byte[length]; MySqlStream.ReadFully(stream, buffer, 0, length); return(buffer); }
private void PrepareNextPacket() { MySqlStream.ReadFully(baseStream, lengthBytes, 0, 7); int compressedLength = lengthBytes[0] + (lengthBytes[1] << 8) + (lengthBytes[2] << 16); // lengthBytes[3] is seq int unCompressedLength = lengthBytes[4] + (lengthBytes[5] << 8) + (lengthBytes[6] << 16); if (unCompressedLength == 0) { unCompressedLength = compressedLength; zInStream = null; } else { ReadNextPacket(compressedLength); MemoryStream ms = new MemoryStream(inBuffer); zInStream = new GZipStream(ms, CompressionMode.Compress); } inPos = 0; maxInPos = unCompressedLength; }