• 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
Re: AsyncSocket and buffer for line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AsyncSocket and buffer for line


  • Subject: Re: AsyncSocket and buffer for line
  • From: malcom <email@hidden>
  • Date: Sun, 20 Aug 2006 21:25:21 +0200

Thanks to Dustin V. the solution is:

 -readDataToData:[AsyncSocket CRLFData] withTimeout:tag:

thanks ;)

On 8/20/06, malcom <email@hidden> wrote:
Hello, I would to use AsyncSocket to receive data from server.
I've tried to use NNTP protocol so I need to check if a received line
it's equal to @"." to see if an article text has received.
Unfortunatly AsyncSocket did not return to me a "real server line" but
only the partial received data.

So sometimes instead of receiving
blal bla bla

I could receive
bla bla
bla

but there is not any second line in original text.
How can I make a sort of buffer that merge these fake lines?

I've tried this but it seems not work.

-(void)onSocket:(AsyncSocket *)sock didReadData:(NSData*)data withTag:(long)t {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSString *str = [[[NSString alloc] initWithData:data
encoding:NSISOLatin1StringEncoding] autorelease];

        NSRange range;

        if(!_string) _string = [[NSMutableString alloc] init];

    if(str && [str length] > 0) {
                unsigned int start, stop, cont;

        [_string appendString:str];
        start = stop = cont = 0;
        do {
            range.location = stop;
            range.length = 0;
            [_string getLineStart:&start end:&stop contentsEnd:&cont
forRange:range];
            if(stop != cont) {
                range.location = start;
                range.length = cont - start;
                                [self _preFetchRawData: [_string substringWithRange:range]];
            }
        }
        while(stop != cont);

        range.location = 0;
        range.length = start;
        [_string deleteCharactersInRange:range];
    }
    [pool release];
        [socket readDataWithTimeout: timeout tag: 1];
}



--
www.malcom-mac.com - indipendent software developer
mail: email@hidden
_______________________________________________
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


References: 
 >AsyncSocket and buffer for line (From: malcom <email@hidden>)

  • Prev by Date: Re: Making Cocoa Application Scriptable
  • Next by Date: Re: NSDictionary round trip?
  • Previous by thread: AsyncSocket and buffer for line
  • Next by thread: QTTime
  • Index(es):
    • Date
    • Thread