Hi,
In the wake of this thread thread I'm trying to read binary data from a socket, hence the code:
unsigned int totalBytes = 0;
totalBytes = tcpSocket.bytesAvailable();
if (totalBytes < 4) return; // bogus tx...
uint headerSize=sizeof(uint);
char * header = new char [headerSize];
uint headerBytes=0;
inData.readBytes(header, headerSize);
headerBytes=atoi(header);
unsigned int totalBytes = 0;
totalBytes = tcpSocket.bytesAvailable();
if (totalBytes < 4) return; // bogus tx...
uint headerSize=sizeof(uint);
char * header = new char [headerSize];
uint headerBytes=0;
QDataStream inData(&tcpSocket);
inData.readBytes(header, headerSize);
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.
Bookmarks