• 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: TCP Push function in CFStream?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TCP Push function in CFStream?


  • Subject: Re: TCP Push function in CFStream?
  • From: Quinn <email@hidden>
  • Date: Thu, 9 Oct 2008 09:44:40 +0100

At 5:44 +0800 8/10/08, Liwei wrote:
I'm writing an application that requires low latency. I know that
there is this special bit flag that can be set for a TCP packet called
Push which forces TCP to immediately send the data out without waiting
for its buffer to fill up first.

Looking at data captures from CFStream write operations, it seems that
sometimes the Push flag is set while sometimes it is not. How does
CFStream determine whether the flag is to be set or not and how can I
force it to always flag my data to be pushed?

The TCP push flag isn't what you think it is. In general, it's not under the direct control of application layer code. CFStream has no knob to set the flag, and neither does sockets. The best way to get TCP to transmit data with a low latency is to deliver all of the data to TCP in a single chunk.


For example, let's say your protocol consists of a header followed by a variable amount of data. Rather than writing the header to the stream as one chunk and then writing the data to the stream as a second chunk, write both the header and the data to the stream in a single chunk. In sockets you can write from discontiguous memory using <x-man-page://2/writev> or <x-man-page://2/sendmsg>. There's no direct support for that in CFStream. You would have to assemble the data in a contiguous chunk of memory insteda.

Beyond that there's the TCP_NODELAY option, but that tends to be a mixed blessing. There's lots of discussion of this option on the web, and I suggest you read up on it before you go down that path.

Side question: There is no CFStream for listening right? I have to use
sockets for that?

Yes. If you have a runloop-based application, you can use CFSocket.

Once you've accepted the connection you can create CFStreams for it using CFStreamCreatePairWithSocket.

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
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


References: 
 >TCP Push function in CFStream? (From: Liwei <email@hidden>)

  • Prev by Date: Re: Problem with Network Preferences & System Configuration Framework
  • Next by Date: Re: kCFSocketDataCallBack auto accepts connection?
  • Previous by thread: TCP Push function in CFStream?
  • Next by thread: Question about adding search domains using kSCPropNetDNSSearchDomains
  • Index(es):
    • Date
    • Thread