本文介绍了iOS客户端 - 服务器应用程序:HTTP或TCP / IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将开始设计/开发客户端 - 服务器iOS应用程序。我倾向于使用HTTP请求从服务器获取/发布数据,但希望确保这是正确的决定。使用套接字对http请求的好处是什么?套接字更快?我倾向于http的一个原因是我也想有一个Web界面以及iOS界面。如果我创建的PHP Web服务,iOS和Web应用程序都可以访问,那么我相信我减少开发时间。

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?

提前感谢。

推荐答案

p> HTTP只是TCP上面的一层,所以它也是基于套接字。我将使用HTTP,例如,因为有HTTPS需要安全通信的情况下。与定制的TCP协议相比,HTTP(S)的另一个优点是防火墙通常具有针对其使用的TCP端口的针孔(HTTP:80,HTTPS:443)。

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).

这篇关于iOS客户端 - 服务器应用程序:HTTP或TCP / IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:07