在Windows 7上运行的。net 4.5 WebSocket服务器?

时间:2022-04-25 03:17:27

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?

我知道。net 4.5的ClientWebSocket类在Windows 7上不受支持,但是有可能使用。net 4.5 API在Windows 7上创建一个WebSocket服务器吗?

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

让自己更清楚,在这里和这里,它看起来像服务器端应该支持。net 4.5 WebSocket实现的一部分甚至在Windows 7,然而运行HttpListener并试图访问它使用一个开源WebSocket实现了我一个“Portocol不支持”的错误

2 个解决方案

#1


34  

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).

操作系统的HTTP。系统对websockets的支持仅限于Win8 / Windows Server 2012——我同意这是愚蠢的(它应该是Windows -update的一部分,或者至多是一个服务包,IMO)。

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

这意味着您不能使用来自HttpListener或ASP的WebSockets框架支持。直接净。

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.

但是:至于“是否有可能创建一个WebSocket服务器”——当然……但前提是您自己处理TCP/IP,或者使用第三方库。这有点烦人,但并不像听起来那么糟糕。

Edit: 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).

编辑:经过一些检查,我可以确认这个服务器端组件在Windows 7上不工作(等等);iswebckesotrequest返回false,尽管它是一个带有连接的web-socket请求:升级和升级:websocket(等等)头(来自Chrome会话,这很有帮助)。

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.

然而,我很惊讶地发现客户端部分不能工作,因为:这更简单,不需要(或者至少不需要)涉及HTTP.SYS。尝试使用它们会抛出一个PlatformNotSupportedException。

#2


6  

As Marc says, the Microsoft APIs do not work on Windows 7. However there are several open source libraries that support WebSockets on Windows 7, and in some cases even cross platform via Mono.

正如Marc所说,微软的api不能在Windows 7上运行。然而,有几个开源库支持Windows 7上的WebSockets,在某些情况下甚至可以通过Mono实现跨平台。

#1


34  

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).

操作系统的HTTP。系统对websockets的支持仅限于Win8 / Windows Server 2012——我同意这是愚蠢的(它应该是Windows -update的一部分,或者至多是一个服务包,IMO)。

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

这意味着您不能使用来自HttpListener或ASP的WebSockets框架支持。直接净。

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.

但是:至于“是否有可能创建一个WebSocket服务器”——当然……但前提是您自己处理TCP/IP,或者使用第三方库。这有点烦人,但并不像听起来那么糟糕。

Edit: 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).

编辑:经过一些检查,我可以确认这个服务器端组件在Windows 7上不工作(等等);iswebckesotrequest返回false,尽管它是一个带有连接的web-socket请求:升级和升级:websocket(等等)头(来自Chrome会话,这很有帮助)。

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.

然而,我很惊讶地发现客户端部分不能工作,因为:这更简单,不需要(或者至少不需要)涉及HTTP.SYS。尝试使用它们会抛出一个PlatformNotSupportedException。

#2


6  

As Marc says, the Microsoft APIs do not work on Windows 7. However there are several open source libraries that support WebSockets on Windows 7, and in some cases even cross platform via Mono.

正如Marc所说,微软的api不能在Windows 7上运行。然而,有几个开源库支持Windows 7上的WebSockets,在某些情况下甚至可以通过Mono实现跨平台。