Я пытаюсь записать байты через сервер с помощью этой функции:
case NSStreamEventHasSpaceAvailable:
- - - - - - -
- - - - - - -
--- - - - - --
NSInteger bytesWritten;
bytesWritten = [self.oStream write:[self.data5 bytes] maxLength:[self.data5 length]];
if (bytesWritten <= 0) {
NSLog(@"No Byte written");
} else {
NSLog(@" Byte written");
[self.data5 replaceBytesInRange:NSMakeRange(0, bytesWritten) withBytes:NULL length:0];
space = YES;
}
Здесь показано, что байты записываются, когда в случае
case NSStreamEventHasBytesAvailable:
NSLog(@"Bytes available");
NSInteger bytesRead;
NSUInteger bufferLength;
bufferLength = [ inputBuffer length];
if (bufferLength == self.inputBufferCapacity) {
NSLog(@"Error");
} else {
// Temporarily increase the size of the buffer up to its capacity
// so as to give us a space to read data.
[self.inputBuffer setLength:self.inputBufferCapacity];
// Read the actual data and respond to the three types of return values.
bytesRead = [iStream read:((uint8_t *) [self.inputBuffer mutableBytes]) + bufferLength maxLength:self.inputBufferCapacity - bufferLength];
Здесь я получаю отрицательное значение в bytesRead. Пожалуйста, помогите мне, где мне не хватает кода.