• 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: Recommended API for two-way transfers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recommended API for two-way transfers


  • Subject: Re: Recommended API for two-way transfers
  • From: Becky Willrich <email@hidden>
  • Date: Mon, 4 Feb 2002 12:10:03 -0800

So, I'm trying to figure out what my options are. OTMP is definitely a
possibility since it gives me backwards compatibility with MacOS 9. But I'm
open to going MacOS X only. So bsd sockets, CFSocket, or anything else are
on the table.

The key to figuring out which model works best, is the fact that I need to
transmit and receive data simultaneously. This is not request/response type
of protocol.

On X, you will get the most bandwidth using raw sockets; we've managed to clock pretty near ideal throughput between two 100 Mhz machines with both sides doing nothing but reading and writing as fast as possible (each side both reads and writes). Using CFStream adds a slight memory overhead, but achieves the same throughput rate. However, that's if you use it in a blocking fashion, which in most cases is not what you'll want (you don't want to risk being blocked in read when you have bytes that need to be written).

For non-blocking models, bsd sockets + select will give you the best bandwidth and be the closest to the metal, but both CFSocket and CFStream (which is built on top of CFSocket) are so close to this that unless you anticipate > 500 Mb/s traffic, I very much doubt you'll see the penalty. The overhead comes from having to run the runloop to receive the event notifications; we were only able to see the cost when talking to the loopback address (even hitting the localhost's IP address was not sufficient). If you're comfortable with CFRunLoop, or you have to multiplex the socket traffic with other activities (UI activity, mach messaging), this is definitely the way to go. However, CFSocket and CFStream are both works-in-progress on X; CFSocket is available starting in 10.0, but has significant enhancements in 10.1 and in more recent updates. CFStream is available only starting in 10.1. Both CFSocket and CFStream allow you to control the read and write directions on a socket separately (they're actually separate objects with CFStream).

Hope that helps,
REW


References: 
 >Recommended API for two-way transfers (From: Chris Silverberg <email@hidden>)

  • Prev by Date: Re: Network Programming Models (was OTCountFreeBytes?)
  • Next by Date: Re: Network Programming Models (was OTCountFreeBytes?)
  • Previous by thread: Recommended API for two-way transfers
  • Next by thread: Re: Network Programming Models (was OTCountFreeBytes?)
  • Index(es):
    • Date
    • Thread