\0 is interpreted as the end of a string so appending it to a string will have no useful result without telling the callee the size of the character array. So either don't append null bytes to the array (as it already contains a null character at the end) and/or pass the size of the array to the callee. Or use QByteArray:
Qt Code:
  1. QByteArray ba = "data";
  2. ba.append('\0');
  3. socket->write(ba);
To copy to clipboard, switch view to plain text mode