发送应用程序C#之间的插座 [英] Send a socket between applications c#

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

问题描述

我想知道如果有,你有一个.NET应用程序的名称,其中的appA收到TCP套接字连接,然后根据一定的规则将发送套接字连接到另一个名为
.NET应用程序的方式程序appB。
我知道这违反了安全性和良好做法很多,但将是有趣的,如果它是可能的。

I would like to know if there is a way where you have a .net app name appA where it receives a tcp socket connection and then according to some rules will send the socket connection to another .net app named appB. I know this violates alot of security and good practice,but would be interesting if it would be possible.

推荐答案

代理

一种选择是让APPA的代理。也就是说,它接受连接,并代表客户端连接到APPB - 而仅仅是将数据转发

One option is to make AppA a proxy. That is, it accepts the connections, and connects on behalf the client to AppB - and merely forwards the data.

插座复制

您真正需要的解决方案是的 Socket.DuplicateAndClose() (请务必仔细阅读的文档)。它可以让你转移进程之间的套接字的控制

The solution you are really looking for is Socket.DuplicateAndClose() (make sure you read the documentation carefully). This allows you transfer the control of a socket between processes.

通常你会:


  • 开始APPA,APPB和APPC。

  • 使用远程允许APPA与APPB和APPC通信。

  • 当连接到发APPA,确定谁发给和:

    • 复制和APPA关闭套接字

    • 发送插座子进程。通过远程处理。

    • 使用插座(SocketInformation)构造函数打开APPB插座。

    • Start AppA, AppB and AppC.
    • Use remoting to allow AppA to communicate with AppB and AppC.
    • When a connection is made to AppA, determine who to send it to and:
      • Duplicate and close the socket in AppA.
      • Send the socket to the child process via remoting.
      • Open the socket in AppB using the Socket(SocketInformation) constructor.

      这篇关于发送应用程序C#之间的插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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