public override void WritePacket(MySqlStreamWriter writer)
 {
     writer.ReserveHeader();//allocate header
     if (protocol41)
     {
         writer.WriteUnsigned4(clientFlags);
         writer.WriteUnsigned4(maxPacketSize);
         writer.WriteUnsigned1(charsetNumber);
         writer.WriteFiller(23);
         writer.WriteNullTerminatedString(user);
         writer.WriteLengthCodedBuffer(scrambleBuff);
         writer.WriteNullTerminatedString(database);
     }
     else
     {
         writer.WriteUnsigned2(clientFlags);
         writer.WriteUnsigned3(maxPacketSize);
         writer.WriteNullTerminatedString(user);
         writer.WriteBuffer(scrambleBuff);
         if (database != null && database.Length > 0)
         {
             writer.WriteFiller(1);
             writer.WriteBuffer(Encoding.ASCII.GetBytes(database));
         }
     }
     _header = new PacketHeader(writer.OnlyPacketContentLength, writer.IncrementPacketNumber());
     writer.WriteHeader(_header);
 }