如何在远程系统上进行2个.NET程序的通信 [英] How to make 2 .NET programs on remote systems communicate

查看:81
本文介绍了如何在远程系统上进行2个.NET程序的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请和我一起露面;我是一位经验丰富的C#程序员,但我对ASP.NET没有任何经验。我不是在这里要求一个完整的解决方案,只是从哪里开始的一些指导。



这是我想要做的:我有一个运行的应用程序客户机器。在某些情况下,我想让该应用程序能够向托管另一个.NET应用程序的服务器发送请求。当服务器收到此消息(以及参数)时,服务器执行.NET程序并将结果返回给客户端,客户端应用程序可以在其中接收它并相应地运行。



我希望这个问题对于某人指向正确的方向并不太一般......

Please bare with me; I am a pretty experienced C# programmer, but I do not have any experience with ASP.NET. I am not asking for a full solution here, just some guidance in terms of where to start.

Here's what I want to do: I have an application which runs on client machines. In certain situations, I want to make that application be able to send a request to a server, where another .NET application is hosted. When the server receives this message (along with parameters), the server executes the .NET program and returns the result to the client, where the client application is able to receive it and behave accordingly.

I hope this question is not too general for someone to point me in the right direction...

推荐答案

其中一种方法可能就像这个



在服务器端:

构建基于异步Windows服务的套接字/命名管道。此应用程序将加载可执行文件,等待可执行文件的结果并将响应返回给客户端应用程序。



您需要处理的挑战如下

*设计Windows服务本身就是一个挑战

*多线程并不像我们想象的那么容易

*通信错误处理。

*创建执行其他应用程序的过程并从中获取结果





在客户端:

构建一个简单的套接字客户端应用程序,它向服务器发送请求并等待响应并做相应的事情。



自从它双向通信,这就是建议基于通信的应用程序的原因,否则可以使用服务器端的Web服务来实现。
One of the approach could be like this

At Server End:
Build a socket/named pipe based Asynchronous Windows Service. This application will load the executable, wait for the result from the executable and return the response back to the client application.

The challenges here that you need to handle is following
* Designing Windows Service is itself a challenge
* Multithreading is not as easy as we think
* Communication Error Handling.
* creating process to execute the other application and gets result from it


At Client End:
Build a simple socket client application which send request to the server and wait for the response and do things accordingly.

Since its a two way communication that's why a communication based applications is suggested otherwise the same could be achieve using Web Service at server end.


几年前,我为同样的情况创建了一个解决方案。

我创建了一个基于TCPClient的程序,它作为一个服务器应用。这是一个简单的tcp客户端,正在侦听一些给定的端口。当任何客户端连接时,它可以通过其他tcpClient发送接收数据。在客户端机器上,有一个tcp客户端作为用户。在特定端口上发起连接请求。它获取连接字符串,然后在该特定端口上进行通信。



您可能需要在.Net中学习TCPClient类。

该解决方案是用C#.Net编写。

它是服务器端的多线程应用程序。

连接后,每个客户端都在不同的线程中处理。特别是拥有监听线程。
Some years ago i created a solution for same situation.
I created a TCPClient based program that was running as a server app. it was a simple tcp client that was listening some given ports. when any client connects it can send receive data through an other tcpClient. on client side machine, there was a tcp client as user. that initiated a connection request on specific port. it gets connection string and then communicate on that specific port.

You may need to study TCPClient class in .Net.
That solution was written in C#.Net.
It was a multi threaded app at server side.
After connect, each client was handled in different thread. specifically own listening thread.


转到网络服务 [ ^ ]。

看到这个@ @ a href = http://msdn.microsoft.com/en-us/library/ff649954.aspx\">MSDN [ ^ ]



.NET中有两种类型的服务

1.) ASMX [ ^ ]

2.) WCF [ ^ ]



您可能会发现这两者之间存在差异此处 [ ^ ]。



-KR
Go for Web Services[^].
See this as well @ MSDN[^]

Two types of services are there in .NET
1.) ASMX[^]
2.) WCF[^]

you may find the difference between these two here[^].

-KR


这篇关于如何在远程系统上进行2个.NET程序的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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