无状态协议和有状态协议 [英] stateless protocol and stateful protocol

查看:1582
本文介绍了无状态协议和有状态协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何理解无状态协议和状态协议? HTTP是无状态协议,FTP是有状态协议。对于需要大量交互的Web应用程序,底层协议应该是有状态的。我的理解是对的吗?

How to understand stateless protocol and stateful protocol? HTTP is a stateless protocol and FTP is a stateful protocol. For the web applications requiring a lot of interactions, the underlying protocol should be stateful ones. Is my understanding right?

推荐答案

由于您询问的是Web应用程序,协议将始终是无状态的 - Web的协议是http (或https),这就是她写的全部内容。

Since you're asking about a Web application, the protocol will always be stateless -- the protocol for the Web is http (or https), and that's all she wrote.

我认为你所想的是在你的Web应用程序本身提供一种状态机制。典型的方法是在Web应用程序中创建用户会话的唯一标识符(一种或另一种形式的会话ID是常见做法),它在浏览器和服务器之间来回传递。这通常是在cookie中完成的,虽然它可以完成,根据您的平台/框架,在URL上也会有一些麻烦。

I think what you're thinking of is providing a state mechanism in your Web application itself. The typical approach to this is that you create a unique identifier for the user's session in your Web application (a sessionID of one form or another is the common practice) which is handed back and forth between browser and server. That's typically done in a cookie, though it can be done, with a bit more hassle for you depending on your platform/framework, on the URL as well.

您的服务器-side代码存储有状态信息(同样,通常称为用户会话)但是它想要使用sessionID来查找它。 http流量只是回送sessionID。只要该标识符存在,每个http事务完全独立于所有其他事务,因此协议流量本身是无状态的。

Your server-side code stores stateful information (again, typically called the user's session) however it wants to using the sessionID to look it up. The http traffic simply hands back the sessionID. As long as that identifier is there, each http transaction is completely independent of all others, hence the protocol traffic itself is stateless.

这篇关于无状态协议和有状态协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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