NSInputStream is being truncated
NSInputStream is being truncated
- Subject: NSInputStream is being truncated
- From: Lou Brothers <email@hidden>
- Date: Fri, 2 Sep 2005 16:27:31 -0400
Hello,
I'm attempting to read from an NSInputStream. Most of the messages I
receive are rather short (<500 characters), however some are rather
long (> 2000 characters). Everything is fine for the short messages
but when I read the long message I get it in two parts.
I've tried changing the buffer and maxLength sizes, but that does not
help. Is there an intrinsic size limitation I should be aware of or
is there something else going on with my code? I have attached the
code below:
NSData *messageData = nil;
uint8_t buffer[1024];
int bytesRead = 0;
NSString *messageString = nil;
//Reading the stream...
case NSStreamEventHasBytesAvailable:
bytesRead = [(NSInputStream *)stream read:buffer
maxLength:1024];
messageData = [NSData dataWithBytes:buffer
length:bytesRead];
messageString = [[NSString alloc]
initWithData:messageData encoding:NSUTF8StringEncoding];
//Display the string and process further
}
[messageString release];
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden