iOS client-server app: HTTP or TCP/IP?

galactikuh picture galactikuh · Dec 13, 2011 · Viewed 9k times · Source

I am about to start designing/developing a client-server iOS app. I am leaning towards using HTTP requests to get/post data from/to a server, but want to make sure this is the right decision. What are the benefits of using sockets over http requests. Are sockets faster? One reason I am leaning towards http is that I also want to have a web interface as well as iOS interface. If I create PHP web services that the iOS and web application can both access, then I believe I am reducing development time.

By the way, I have read through these tutorials, which provide some benefits of sockets, but none of the benefits mentioned are necessarily game changers. Except that I don't completely understand what he means by "You can send just the exact data you need to send – making your protocol lean and efficient." Does anyone know what he means here?

Thanks in advance.

Answer

kol picture kol · Dec 13, 2011

HTTP is just a layer above TCP, so it's also "socket-based". I would use HTTP, for example because there is HTTPS for the cases when secure communication is needed. Another advantage of HTTP(S) over a custom-made TCP-protocol is that firewalls usually have a pinhole for the TCP port it uses (HTTP: 80, HTTPS: 443).