socket编程和Http编程的区别 [英] difference between socket programming and Http programming

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

问题描述

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

解决方案

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

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

另一方面,套接字是大多数操作系统提供的用于与网络通信的 API.socket 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.

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

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