Can two separate writeData to arrive at the receiver end as a single piece of data?

59 views
Skip to first unread message

AL1

unread,
May 1, 2012, 10:53:14 AM5/1/12
to CocoaAsyncSocket
I encountered a situation where two separate writeData arrived at the
receiver as a single piece of data. I needed them to be arrived
separately.

For example: (data1 is very small when compared to data2)

1st write:

[data1 appendData:[GCDAsyncSocket CRLFData]];
[tcpSocket writeData:data withTimeout:-1.0 tag:0];

2nd write:

[tcpSocket writeData:data2 withTimeout:-1.0 tag:0];

It works fine for the first occurrence of sequence above (1st and
2nd). But if I repeated the sequence continuously, I noticed that
data1 and data2 arrived at the receiver end as a single piece of
data. It only happens if the file size is larger than 8 or 9MB. And
it happened immediately right after the first successful of the
sequence above.

(if data2 above is less than 8MB, then it worked fine continuously.)

AL1

unread,
May 1, 2012, 6:44:19 PM5/1/12
to CocoaAsyncSocket
Problem solved: I overlooked that the writeData is an asynchronous
operation!

Steve Crossman

unread,
May 2, 2012, 8:22:55 AM5/2/12
to cocoaasy...@googlegroups.com
Is it possible to have the Socket Server make a broadcast to all clients via Bonjour or must the client initiate the call to the Server?

How would you do this, if possible?

Steve

~ thanks for this great resource !!!

Robbie Hanson

unread,
May 4, 2012, 4:02:43 PM5/4/12
to cocoaasy...@googlegroups.com
Also keep in mind that TCP is a stream:
https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls

-Robbie Hanson
Sent from my iPhone
> --
> You received this message because you are subscribed to the Google Groups "CocoaAsyncSocket" group.
> To post to this group, send email to cocoaasy...@googlegroups.com.
> To unsubscribe from this group, send email to cocoaasyncsock...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cocoaasyncsocket?hl=en.
>

AL1

unread,
Jun 4, 2012, 4:00:55 PM6/4/12
to CocoaAsyncSocket
Good writing. I revisited it couple times!

On May 4, 3:02 pm, Robbie Hanson <robbiehan...@deusty.com> wrote:
> Also keep in mind that TCP is a stream:https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls
>
> -Robbie Hanson
> Sent from my iPhone
>
Reply all
Reply to author
Forward
0 new messages