It seems to work fine except for one particular edge case I found where the last message is never received . or processed.
I went into the code and I changed the read buffer size, and it worked ( in the - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode method) .
Code: Select all
case NSStreamEventHasBytesAvailable:{
uint8_t buf[1023];
NSInteger len = 0;
len = [(NSInputStream *)stream read:buf maxLength:1023];
}
Note: it is normally 1024
So now is this a possible bug in the client code? Perhaps the packet handling logic doesn't account for some edge case where the packet length is XXX bytes or so?
Or is there something I'm doing wrong on the server side of things that could be causing this.
Please advise.