• 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: NSFileHandle -availableData breaks stdin stream at 4K chunks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileHandle -availableData breaks stdin stream at 4K chunks?


  • Subject: Re: NSFileHandle -availableData breaks stdin stream at 4K chunks?
  • From: Greg Parker <email@hidden>
  • Date: Wed, 02 Jul 2014 17:44:21 -0700

On Jul 2, 2014, at 5:34 PM, Jerry Krinock <email@hidden> 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     email@hidden     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: NSFileHandle -availableData breaks stdin stream at 4K chunks?
      • From: Jerry Krinock <email@hidden>
References: 
 >NSFileHandle -availableData breaks stdin stream at 4K chunks? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: NSFileHandle -availableData breaks stdin stream at 4K chunks?
  • Next by Date: Re: NSTableView automatic column size
  • Previous by thread: Re: NSFileHandle -availableData breaks stdin stream at 4K chunks?
  • Next by thread: Re: NSFileHandle -availableData breaks stdin stream at 4K chunks?
  • Index(es):
    • Date
    • Thread