On Jul 2, 2014, at 5:34 PM, Jerry Krinock <je...@ieee.org> wrote:
> I’m writing a tool which receives data streamed into stdin by my Google 
> Chrome extension (using their new Native Messaging API).  I think they use 
> stdin for such interprocess communication in order to make it cross-platform.
> 
> Anyhow, I was surprised to find that the following code, which repeatedly 
> invokes -waitForDataInBackgroundAndNotify and -availableData on 
> +[NSFileHandle fileHandleWithStandardInput], delivers no more than 4096 bytes 
> on each iteration.  It just stops at 4096, and the next -availableData starts 
> with the next byte.
> 
> Although it was fun to write the code to buffer and stitch the message fields 
> and length fields back together, I’d like to know what is causing these 4K 
> breaks.

The kernel, probably. 

Output streamed from one process to another needs to be buffered somewhere. I 
think the kernel's pipe and/or pty implementation uses a 4K buffer. 


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler



_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to