views:

347

answers:

2

I sent a multi-line data which length is more than 20 i'm sure because i've test to get the data using terminal "cn" command , but if i read the data using asyncsocket like this:

-(void)onSocket:(AsyncSocket )sock didReadData:(NSData)data withTag:(long)tag{ NSLog([NSString stringWithFormat:@"%d",[data length]]); }

I only get length of 20.. I think that's because asyncsocket only read first line of my data which length is 20. My question: How to read all data? i don't want the asyncsocket to only read my first line of data.

thanks.

A: 

nvm... i forget to put this on sock didReadData [sck1 readDataWithTimeout:-1 tag:0]; so the read cycle stopped after the first line.

A: 

I have a similar issue, I am sending a file but receives only part and delegate method didReadData: is called. Here I am using

[socket readDataWithTimeout:-1 tag:0]

Because at receiving party it does not know how many bytes to read. And I am sending an image so how can I get every read ?

Thanks

Tharindu Madushanka
oops I had to do a similar thing in my delegate method and create the image at when socket disconnect delegate method was called. It went alright then.
Tharindu Madushanka