Scott, Yes, TCP has the boundary issue. So I put a "\n" at the end of each XML. And there is no "\n" within any XML.
Thanks! Bing On Thu, Jun 16, 2011 at 3:13 AM, Scott Ribe <scott_r...@elevated-dev.com>wrote: > On Jun 15, 2011, at 1:04 PM, Bing Li wrote: > > > I test the program just on a single Mac machine using TCP, i.e., both the > client and the server are located on the same machine. So I think it is > impossible that the data is corrupted during the transmission. > > Correction to my prior post: even if all your strings are < 1024 bytes, you > still have no guarantee that they won't be broken in the middle of a > multi-byte sequence. On the sending end, multiple short strings might get > packed into a single packet > 1024 bytes. Your receiving end is not going to > be reliable unless you only use 7-bit ASCII--and even then you need the > appropriate logic in receivedMessage to recognize message boundaries, append > bytes to a buffer until you have a full message, and so on. > > -- > Scott Ribe > scott_r...@elevated-dev.com > http://www.elevated-dev.com/ > (303) 722-0567 voice > > > > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com