• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSInputStream is being truncated
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Embedding a framework...
  • Next by Date: Re: Embedding a framework...
  • Previous by thread: Re: [super initialize]?
  • Next by thread: Preventing Opening a New Document When Clicking Active Program in Dock
  • Index(es):
    • Date
    • Thread