• 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
Does CFWriteStream coalesce writes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Does CFWriteStream coalesce writes?


  • Subject: Does CFWriteStream coalesce writes?
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 29 May 2008 11:06:42 -0700

My BLIP[1] protocol uses asynchronous NSStreams for TCP I/O. I'm a bit unsure about the efficiency of the recommended[2] technique for writing to the stream. Specifically, the examples suggest making _one_ write call per NSStreamEventHasSpaceAvailable notification. This works, since if there's more space available, the notification will be sent again, resulting in another write.

My worry: Will this result in CFNetwork making multiple small write syscalls? If so, if the writes are smaller than the network packet size (the example uses only 1kbyte) will this result in TCP inefficiently sending multiple small packets?

Or do my consecutive writes get buffered together by CFNetwork or the kernel and stuffed into full-size packets? (I'm sure this has something to do with the TCP Nagle algorithm, but my understanding of that is fuzzy at best.)

(Some of my writes are as small as 12 bytes, the size of a message header in my protocol. At first I was calling the stream's write method multiple times in my event handler, but I found that if the stream ran out of room the second write could block, even though the stream is ostensibly in non-blocking mode. So I went back to issuing only a single write per event.)

—Jens

[1] http://mooseyard.com/projects/MYNetwork/
[2] file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/Streams/Articles/WritingOutputStreams.html

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Does CFWriteStream coalesce writes?
      • From: Mark Pauley <email@hidden>
  • Prev by Date: Re: SCTP?
  • Next by Date: Re: Does CFWriteStream coalesce writes?
  • Previous by thread: Re: CFNetwork caching HTTPS
  • Next by thread: Re: Does CFWriteStream coalesce writes?
  • Index(es):
    • Date
    • Thread