On Thu, Jan 14, 2010 at 1:11 PM, Christian Ziegler <chris.zieg...@me.com> wrote:
> Hi all!
>
> It is probably simple, but I can't figure it out atm. I  want to send an 
> archived object through an NSPipe to a child process. As long as there is 
> only a single object in the pipe at a given time the receiver can unarchive 
> the object properly. However, once I send another object to the pipe, 
> unarchiving raises the error "uncomprehensible archive". I played around with 
> all three read methods but nothing worked. How can I distinguish between 
> several objects in the pipe? Maybe I can write an EOF indicator to the pipe 
> somehow?

Pipes are implemented in the kernel by a fixed sized buffer. I don't
remember exactly how large it is, but let's say it's 4K. Any data sent
under 4K can be transmitted at once, but data over 4K will come in
multiple chunks. It's your job on the receiver end to store those
chunks until you have it all. Then do the unarchiving.

My guess is that your single archive is less than 4K, but two archives
together is more. What you need to do is develop a protocol to send
data over the pipe. Very simply, you could send a 32bit integer first
indicating how many bytes are in the archive. Then read until you get
that many from the pipe. Repeat.

Keeping in mind that I used 4K in my explanation, but the actually
pipe buffer may be more or less.
_______________________________________________

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

Reply via email to