套接字编程和Http编程之间的区别 [英] difference between socket programming and Http programming

查看:141
本文介绍了套接字编程和Http编程之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

套接字编程和Http编程有什么区别?有人可以帮忙吗?

解决方案

HTTP是一种应用程序协议.基本上,这意味着HTTP本身不能用于将信息传输到远程端点或从远程端点传输信息.相反,它依赖于基础协议,在HTTP的情况下,该协议是TCP.

如果您有兴趣,可以阅读有关 OSI层的更多信息.

另一方面,套接字是大多数操作系统提供的能够与网络通信的API.套接字API支持从传输层到底层的不同协议.

这意味着,如果您想使用TCP,则可以使用套接字.但是,您也可以使用套接字通过HTTP进行通信,但是随后您必须根据HTTP规范对消息进行解码/编码( RFC2616 ).由于这对于大多数开发人员而言可能是一项艰巨的任务,因此我们还在开发人员框架(如.NET)中提供了现成的客户端,例如WebClientHttpWebRequest类.

What is the difference between socket programming and Http programming? can anyone help please?

解决方案

HTTP is an application protocol. It basically means that HTTP itself can't be used to transport information to/from a remote end point. Instead it relies on an underlying protocol which in HTTP's case is TCP.

You can read more about OSI layers if you are interested.

Sockets on the other hand are an API that most operating systems provide to be able to talk with the network. The socket API supports different protocols from the transport layer and down.

That means that if you would like to use TCP you use sockets. But you can also use sockets to communicate using HTTP, but then you have to decode/encode messages according to the HTTP specification (RFC2616). Since that can be a huge task for most developers we also got ready clients in our developer frameworks (like .NET), for instance the WebClient or the HttpWebRequest classes.

这篇关于套接字编程和Http编程之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆