开发者

Passing a socket to a new AppDomain

I'm working on porting a client/server application to .NET.开发者_JAVA百科 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜