Hi,

In the wake of this thread thread I'm trying to read binary data from a socket, hence the code:
Qt Code:
  1. unsigned int totalBytes = 0;
  2. totalBytes = tcpSocket.bytesAvailable();
  3. if (totalBytes < 4) return; // bogus tx...
  4.  
  5. uint headerSize=sizeof(uint);
  6. char * header = new char [headerSize];
  7.  
  8. uint headerBytes=0;
  9. QDataStream inData(&tcpSocket);
  10.  
  11. inData.readBytes(header, headerSize);
  12. headerBytes=atoi(header);
To copy to clipboard, switch view to plain text mode 

Unless I really don't know what I'm doing... (most probably) why does inData.readBytes(header, headerSize); always cause a segfault?

Any pointers welcome.
Thanks in advance,
Pedro Doria Meunier.