在应用程序之间发送套接字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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代理
一种选择是让 AppA 成为代理。也就是说,它接受连接,并代表客户端连接到 AppB - 并且仅转发数据。
套接字复制
您真正寻找的解决方案是
Socket.DuplicateAndClose()
(请确保仔细阅读文档)。这允许您在进程之间转移套接字的控制权。通常您会:
Socket(SocketInformation)
构造函数在 AppB 中打开套接字。Proxy
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 Duplication
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.Typically you would:
Socket(SocketInformation)
constructor.无需转发连接,它可以用作中间人
No need to forwarding the connection, it can be use to act as a middle men