[英]ASP.NET & TCP Server Solution
My server has two applications running on it: 我的服务器上运行了两个应用程序:
What I need is: 我需要的是:
eg A simple chat program where a client sends “Hi” and server responds “Welcome” . 例如,一个简单的聊天程序,客户端发送“Hi” ,服务器响应“Welcome” 。 The ASP .NET should show a log of this conversation as it happens.
ASP .NET应该显示此对话的日志。 Immediately.
立即。 And if I click a button on the ASP application, it should send a message on behalf of the socket server to the client “You have been accepted onto the server”
如果我单击ASP应用程序上的按钮,它应该代表套接字服务器向客户端发送消息“您已被接受到服务器上”
For the most part, the messages are going to be fairly short like the ones shown here. 在大多数情况下,消息将像这里显示的那样短。
What is the best way to do A and B? 做A和B的最佳方法是什么?
if your "messages" are mostly textual, you may want to take a look at SignalR . 如果您的“消息”主要是文本消息,您可能需要查看SignalR 。
SignalR is a new library for asp.net to enable real-time web functionality. SignalR是asp.net的新库,用于启用实时Web功能。
It uses websockets (or long polling if websockets is unavailable at server/client). 它使用websockets(如果websockets在服务器/客户端不可用,则使用长轮询)。
It has support for different client types. 它支持不同的客户端类型。
SignlaR is a good solution if you're getting the messages from another SignalR client (web page). 如果您从另一个SignalR客户端(网页)获取消息,SignlaR是一个很好的解决方案。
But what if these messages are being sent from a 3rd system over TCP/IP? 但是如果这些消息是通过TCP / IP从第三个系统发送的呢? Then you need to open a TCP port in the ASP.NET Web Application and after receiving a message you have to push it to the web clients.
然后,您需要在ASP.NET Web应用程序中打开TCP端口,并在收到消息后将其推送到Web客户端。
But the question is, what is the best way to have such a TCP Listener hosted in a Web Application (ASP.NET)? 但问题是,在Web应用程序(ASP.NET)中托管这样的TCP侦听器的最佳方法是什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.