在C#Web应用程序使用的WebSockets? [英] Using WebSockets in a C# Web Application?

查看:620
本文介绍了在C#Web应用程序使用的WebSockets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道它可以使用沿着一侧的web应用程序,但进出口运行一个控制台应用程序想知道,如果它可以使用C#的Web应用程序的请求创建的WebSockets使用C#中的WebSockets。

I know its possible to use WebSockets within C# using a console application running along side the web application but Im wondering if its possible to use the requests on the C# web application to create the WebSockets.

我一直在寻找通过ASP.Net和Im开始认为这不会是可能的,除非我用直线上升C#和创建自己的HTTP服务器,然后使用相同的Socket对象生成Web套接字(类似的方式节点.js文件和Socket.IO工作)。

I've been looking through ASP.Net and Im starting to think it wont be possible unless I use straight up C# and create my own HTTP server and then use the same socket object to generate Web Sockets (similar to the way Node.js and Socket.IO work).

这是方式包括一个C#Web应用程序的WebSockets有什么想法,而无需多台服务器/项目?

Any thoughts on ways to include WebSockets on a C# web application without having multiple servers / projects?

推荐答案

这是可能的一个ASP.NET的背景下举办的WebSockets服务器。但是,你需要知道,ASP.NET应用程序可以重新启动,这意味着服务器将被关闭,并需要使用ASP.NET应用程序一起被重新建立。

It's possible to host a WebSockets server within the context of an ASP.NET. However, you'll need to be aware that the ASP.NET application can be restarted which means the server will be shut down and will need to be re-established along with the ASP.NET application.

托管一个单独的Windows服务中的WebSockets应用程序将提供套接字服务器更高的可靠性,但随后会要求IPC的ASP.NET应用程序和Windows服务之间共享数据。

Hosting the WebSockets application within a separate Windows Service would provide greater reliability in the socket server, but then will require IPC to share data between the ASP.NET application and the Windows Service.

所以,有一个权衡讨论。这取决于你的客户端code敏感度的连接损耗和重新建立。如果这是足够的处理,然后在ASP.NET主机将被罚款。

So, there's a trade-off to discuss. It depends on how sensitive your client code is to connection loss and re-establishment. If this is handled sufficiently then hosting within ASP.NET will be fine.

请注意,虽然WebSockets的是新的HTML,这一概念已存在多年Flash和Java小程序。特别是随着闪存它常用于网络游戏和网络聊天。

Note that while WebSockets are new to HTML, the concept has existed for many years with Flash and Java Applets. Especially with Flash it's commonly used for online games and web-based chat.

这篇关于在C#Web应用程序使用的WebSockets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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