• 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: Wise? Stupid? Somewhere in between? Thinkin' out loud...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wise? Stupid? Somewhere in between? Thinkin' out loud...


  • Subject: Re: Wise? Stupid? Somewhere in between? Thinkin' out loud...
  • From: Quinn <email@hidden>
  • Date: Fri, 16 Jul 2004 10:54:05 +0100

At 23:19 -0700 13/7/04, Dakidd wrote:
Ideally, I want to call ReadFrom(ConnectionRef, Buffer, BufferLength) and
get back either a positive number indicating the number of bytes read into
the buffer, a zero (Nothing available, try again later) or an OSStatus to
signal an error. Blocking is to be avoided if at all possible - No data on
this connection? Go deal with something else until some arrives.

Right. This is basically a polled API, and you can implement that trivially using OT. Just put the endpoint into a non-blocking mode (that is, anything except sync/blocking), and OTRcv works pretty much like this.

Using a polled API is simple enough, but it doesn't translate well to modern platforms (even modern versions of traditional Mac OS). I go over this in some detail in the OTMP readme.

<http://developer.apple.com/samplecode/OTMP/OTMP.html>

You basically have a choice. You can either poll frequently, in which case you burn CPU cycles (and battery life on a portable), or you can poll frequently, in which case you set an upper bound on your transfer speed. If you're writing a specific application, you can use application-specific knowledge to determine the polling rate. For example, a program that uses networking just to see if a new update is available can poll at a very low frequency, because the bandwidth is very low. However, if you're writing a generic library, you have to come up with some general solution. This is not easy, especially if you need to deal with traditional Mac OS (where WaitNextEvent pretty much forces you into a polled model).

If I was in your situation (programming for my own hardware, stuck on traditional Mac OS), I'd seriously explore OTMP. It gives you full preemptive networking support on traditional Mac OS, which lets you escape the world of polled I/O. Another nice thing is that you write for OTMP will port to Mac OS X much more easily.

S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Wise? Stupid? Somewhere in between? Thinkin' out loud... (From: Dakidd <email@hidden>)

  • Prev by Date: Admin: Bouncing Emails and Digest Mode
  • Next by Date: Re: Newbie Question follow up
  • Previous by thread: Re: Wise? Stupid? Somewhere in between? Thinkin' out loud...
  • Next by thread: Re: Wise? Stupid? Somewhere in between? Thinkin' out loud...
  • Index(es):
    • Date
    • Thread