• 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: CFReadStreamCopyProperty() returns NULL?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFReadStreamCopyProperty() returns NULL?


  • Subject: Re: CFReadStreamCopyProperty() returns NULL?
  • From: Jens Alfke <email@hidden>
  • Date: Sun, 8 Feb 2009 14:35:50 -0800


On Feb 8, 2009, at 1:58 PM, John Michael Zorko wrote:

NSURLConnection caches data and doesn't let me, the developer, control how much I read from the socket.  This led to huge memory usage in my iPhone app, as NSURLConnection would happily read way ahead into the stream and cache it, causing the iPhone OS to send my app low memory warnings.

Oh, you must be streaming then. You're right, I don't think it's possible to throttle the rate at which NSURLConnection reads data.

The docs for CFReadStreamOpen say:

Opening a stream causes it to reserve all the system resources it requires. If the stream can open in the background without blocking, this function always returns true. To learn when a background open operation completes, you can either schedule the stream into a run loop with CFReadStreamScheduleWithRunLoop and wait for the stream’s client (set withCFReadStreamSetClient) to be notified or you can poll the stream usingCFReadStreamGetStatus, waiting for a status of kCFStreamStatusOpen orkCFStreamStatusError.


Sounds like you'll need to wait for a response to arrive. Scheduling with a runloop is usually preferable; it's the expected Way Things Are Done in Cocoa/CFNetwork, and it saves you from having to spawn a new thread just to read from the stream.

—Jens

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

References: 
 >CFReadStreamCopyProperty() returns NULL? (From: John Michael Zorko <email@hidden>)
 >Re: CFReadStreamCopyProperty() returns NULL? (From: Jens Alfke <email@hidden>)
 >Re: CFReadStreamCopyProperty() returns NULL? (From: John Michael Zorko <email@hidden>)

  • Prev by Date: Re: CFReadStreamCopyProperty() returns NULL?
  • Next by Date: When is it safe to enable filtering in an NKE?
  • Previous by thread: Re: CFReadStreamCopyProperty() returns NULL?
  • Next by thread: Re: CFReadStreamCopyProperty() returns NULL?
  • Index(es):
    • Date
    • Thread