ASP.net" HttpResponse.IsClientConnected"工作? [英] how does ASP.net "HttpResponse.IsClientConnected" work?

查看:153
本文介绍了ASP.net" HttpResponse.IsClientConnected"工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果HTTP是无连接的,那么ASP.net响应属性,HttpResponse.IsClientConnected检测客户端是如何连接的?

if HTTP is connection-less, how does ASP.net response property, HttpResponse.IsClientConnected detect client is connected or not?

推荐答案

HTTP不是无连接 - 您仍然需要连接才能从服务器接收数据;更准确地说,HTTP是无状态。在HTTP上运行的应用程序很可能实际上是有状态的,但HTTP本身不是。

HTTP is not "connection-less" - you still need a connection to receive data from the server; more correctly, HTTP is stateless. Applications running on-top of HTTP will most likely actually be stateful, but HTTP itself is not.

无连接也可以指使用UDP作为传输的系统TCP。 HTTP主要通过TCP运行,几乎每个真实的Web服务器都期望并返回TCP消息而不是UDP。您可能会在基于UDP的协议(如UPnP)中看到类似HTTP的流量,但由于您希望可靠地传送您的网页,因此将始终使用TCP而不是UDP。

"Connectionless" can also refer to a system using UDP as the transport instead of TCP. HTTP primarily runs over TCP and pretty much every real webserver expects, and returns, TCP messages instead of UDP. You might see HTTP-like traffic in UDP-based protocols like UPnP, but because you want your webpage to be delivered reliably, TCP will always be used instead of UDP.

对于 IsClientConnected ,当您访问该属性时,它会调用当前的 HttpWorkerRequest ,这是当前主机环境实现的抽象类。

As for IsClientConnected, when you access that property it calls into the current HttpWorkerRequest which is an abstract class implemented by the current host environment.


  • IIS7 +实现它,如果它先前收到TCP断开消息(设置字段) )该方法现在将返回 false

  • ISAPI实现(IIS 6)调用IIS内的一个函数来通知调用者如果当前请求/响应上下文中的TCP客户端仍然连接,但可能它在相同的基础上工作:当Web服务器收到TCP超时,断开连接或连接重置消息时,它设置一个标志并让执行继续而不是终止响应生成器线程。

以下是相关的源代码:

  • HttpResponse.IsClientConnected: http://referencesource.microsoft.com/#System.Web/HttpResponse.cs,80335a4fb70ac25f
  • IIS7WorkerRequest.IsClientConnected: http://referencesource.microsoft.com/#System.Web/Hosting/IIS7WorkerRequest.cs,1aed87249b1e3ac9
  • ISAPIWorkerRequest.IsClientConnected: http://referencesource.microsoft.com/#System.Web/Hosting/ISAPIWorkerRequest.cs,f3e25666672e90e8

这篇关于ASP.net" HttpResponse.IsClientConnected"工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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