将套接字传递给新的 AppDomain
我正在致力于将客户端/服务器应用程序移植到.NET。服务器的当前 C 版本有一个用于侦听套接字连接的进程(Windows 服务)的可执行文件。当侦听器接受套接字连接时,它会生成一个新进程来处理该连接。处理程序应用程序是一个单独的可执行文件。
在此应用程序的 .NET 版本中,我希望有一个可执行文件/进程。监听器应该为每个连接创建一个新的AppDomain(以隔离分配给每个客户端的“工作进程”)。我应该如何将套接字从侦听器应用程序域传递到工作人员应用程序域?
谢谢!
I'm working on porting a client/server application to .NET. The current C version of the server has one executable for a process (a Windows service) that listens for socket connections. When the listener accepts a socket connection it spawns a new process to handle that connection. The handler application is a separate executable.
In the .NET version of this application, I'd like to have one executable/process. The listener should create a new AppDomain for each connection (to isolate the "worker process" assigned to each client). How should I pass the socket from the listener app domain to the worker app domain?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我刚刚找到了自己问题的答案。即使我没有将套接字传递给单独的进程,也可以使用 DuplicateAndClose 方法。侦听器只需将自己的进程 ID 传递给 DuplicateAndClose 即可。
解决方案描述如下:
http://blogs.msdn.com/b/malarch /archive/2005/12/14/503884.aspx
如果您想将套接字传递给单独的进程,这也适用。
I think I just found the answer to my own question. The DuplicateAndClose method can be used even though I'm not passing the socket to a separate process. The listener can just pass in its own process ID to DuplicateAndClose.
The solution is described here:
http://blogs.msdn.com/b/malarch/archive/2005/12/14/503884.aspx
This also works if you want to pass the socket off to a separate process.