• 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: How do I separate two concatenated archives in an NSData?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >How do I separate two concatenated archives in an NSData? (From: Charles Crowley <email@hidden>)

  • Prev by Date: Re: Endian-ness of "PkgInfo" file
  • Next by Date: Re: NSControl's not updating
  • Previous by thread: How do I separate two concatenated archives in an NSData?
  • Next by thread: NSSpellChecker setLanguage:
  • Index(es):
    • Date
    • Thread