The best way to wirelessly exchange data between an iPhone and a PC?

So I have a computer (Raspberry Pi) with a camera connected to it. I need my iPhone app to wirelessly get the image from that camera in real time and process it. What is the best way of doing it? Creating an HTTP server on Raspberry and sending requests from the iPhone every split second? Or using a TCP/UDP socket? Or anything else?

I need my iPhone app to wirelessly get the image from that camera in real time and process it.

If you want to do this in real time then you really need to use UDP. The problem with TCP in this situation is that it’s reliable. So, if one packet gets dropped then everything behind that packet stalls waiting for the retransmit. This is good in most cases, but not good for real-time work because, by the time the retransmit has happened, the data being retransmitted is so out of date as to be no longer useful.

There are a couple of drawbacks with using UDP:

  • Using it over the wider Internet can be a challenge. Fortunately that isn’t an issue in your case.

  • The APIs are always a bit clunky as compared to TCP.

This second point is not an issue on Apple platforms because Network framework has great support for UDP (NWListener and NWConnection). Unfortunately your remote peer is not an Apple platform, so you will have to use BSD Sockets there (unless you can find a better UDP API).

Finally, one critical point: Make sure you avoid IP fragmentation. See this thread for more on that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The best way to wirelessly exchange data between an iPhone and a PC?
 
 
Q