Re: How do I separate two concatenated archives in an NSData?
Re: How do I separate two concatenated archives in an NSData?
- Subject: Re: How do I separate two concatenated archives in an NSData?
- From: Jim Correia <email@hidden>
- Date: Fri, 13 Jan 2006 18:10:10 -0500
On Jan 13, 2006, at 3:59 PM, Charles Crowley wrote:
I am using sockets to send objects archived in NSData objects. I am
using NSFileHandle's writeData: to send the archives and
readInBackgroundAndNotify to read them. The problem is that if I
send two close together I get only one notification and the
NSFileHandleNotificationDataItem object seems to be the two
archives concatenated together. When I do unarchiveObjectWithData:
on them I get the first one and the error message "*** +
[NSUnarchiver unarchiveObjectWithData:]: extra data discarded" and
I lose the second one.
Getting them two at a time is fine with me but I'm not sure what a
good way would be to separate them so that I can get both of them.
Any ideas?
Since it sounds like you control both sides of the connection,
structure the data you write in a way that the other side can
unambiguously read it. This is really no different than defining a
binary file structure.
For example:
unsigned int -> length of archived data
data in the length specified
<repeat as necessary>
Jim
_______________________________________________
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