Hi,
I read data from a TCP socket connection, but the server sends me \0 from time to time (which would mark the end of a message). Thus, I do not get the rest of the message.
I read like this:
uint8_t buf[tcpBufferSize];
unsigned int len = 0;
len = [inputStream read:buf maxLength:tcpBufferSize];
if(len > 0) {
NSMutableData* data=[[NSMutableData alloc] initWithLength:0];
[data appendBytes: (const void *)buf length:len];
NSString *s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//here s will be only the part before the \0
[s release];
[data release];
}
for example, if the server sends abc\0de y will only get abc since the \0 marks the end.
How could I receive the whole message??