self.bufferOffset
in your code is the offset of the first read-but-not-yet-written byte in the buffer, therefore you will always have
self.bufferOffset <= kSendBufferSize
This (hopefully) explains why the NSLog() output is limited by 32768.
self.bufferOffset
is not the total number of bytes written.
Remark: As others already have commented, the %zu
format works correctly with a size_t
variable. On a 64-bit platform, size_t
is a 64-bit unsigned integer. Example:
size_t s = 18446744073709551615ULL; // 2^64-1
NSLog(@"%zu", s);
// Output: 18446744073709551615