views:

492

answers:

2

How do I establish an input stream over HTTP for the iPhone? My project is to incrementally pull binary data from an HTTP server to the iPhone. The pattern is to pull some data - this is a scientific app - analyze it for a while, pull more data. Rince, and repeat.

This project is a port of a desktop Java app which relies on InputStream and it's methods readInt, readString, etc. to do this.

Cheers, Doug

A: 

If you want an API that more directly mirrors the Java input stream, you may want to look at the C-based CFNetwork. However, Daniel's suggestion to use the URL Loading System (NSURLRequest, NSURLConnection, etc.) is preferable because it uses Objective-C and is really easy to use in asynchronous mode. It makes more of a break from the old stdio.h functions than the simplistic java.io does, and it's well worth your time to understand it.

invalidname
I would love to use NSURLRequest and NSURLConnection for the reasons you mention. Can you clarify for me how I establish a binary input stream and then incrementally pull data when I need it. I noticed the method NSURLRequest - (NSInputStream *)HTTPBodyStream but I'm unclear on how/when I can call it.Cheers,Doug
dugla