.Net 4.5 WebSocket 服务器在 Windows 7 上运行? [英] .Net 4.5 WebSocket Server Running on Windows 7?

查看:33
本文介绍了.Net 4.5 WebSocket 服务器在 Windows 7 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Windows 7 不支持 .Net 4.5 的 ClientWebSocket 类,但是否可以使用 .Net 4.5 API 创建在 Windows 7 上运行的 WebSocket 服务器?

I know the ClientWebSocket class of .Net 4.5 is not supported on Windows 7, but is it possible to create a WebSocket server running on Windows 7 using the .Net 4.5 API?

根据此处这里,看起来像是服务器端的部分即使在 Windows 7 上也应该支持 .Net 4.5 WebSocket 实现,但是运行 HttpListener 并尝试使用开源 WebSocket 实现访问它时,我得到了不支持 Portocol"错误

To make myself clearer, according to both here and here, it looks like the server side part of the .Net 4.5 WebSocket implementation should be supported even on Windows 7, yet running a HttpListener and trying to access it using an open-source WebSocket implementation got me a "Portocol not supported" error

推荐答案

操作系统级 HTTP.SYS 对 websockets 的支持仅限于 Win8/Windows Server 2012 - 我同意这很愚蠢(它应该是 Windows 的一部分 -更新,或最多一个服务包,IMO).

The OS-level HTTP.SYS support for websockets is limited to Win8 / Windows Server 2012 - which I agree is silly (it should be part of a windows-update, or a service-pack at most, IMO).

这意味着您不能直接从 HttpListener 或 ASP.NET 使用对 WebSockets 的框架支持.

This means that you can't use the framework support for WebSockets from HttpListener or ASP.NET directly.

但是:至于是否可以创建 WebSocket 服务器"-当然......但前提是您自己处理 TCP/IP 通信,或者使用 3rd-party 库.这有点烦人,但并不像听起来那么糟糕.

But: as for "is it possible to create a WebSocket server" - sure... but only if you handle the TCP/IP comms yourself, or use a 3rd-party library for the same. This is a little annoying, but is not as bad as it might sound.

经过一些检查,我可以确认此的服务器端组件在 Windows 7(等)上运行;IsWebSocketRequest 返回 false 即使它是一个带有 Connection: UpgradeUpgrade 的网络套接字请求:websocket(等)标头(来自 Chrome 会话,因为它有帮助).

after some checking, I can confirm that the server-side components for this do not work on Windows 7 (etc); the IsWebSocketRequest returns false even though it is a web-socket request with Connection: Upgrade and Upgrade: websocket (etc) headers (from a Chrome session, as it helps).

然而,我非常惊讶发现客户端部分不起作用,因为:这更简单并且不起作用(或至少,不需要) 涉及 HTTP.SYS.尝试使用它们会引发 PlatformNotSupportedException.

I am, however, very surprised to find that the client-side pieces don't work, because: that is simpler and doesn't (or at least, doesn't need to) involve HTTP.SYS. Trying to use them throws a PlatformNotSupportedException.

这篇关于.Net 4.5 WebSocket 服务器在 Windows 7 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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