After sleeping on it, I thought that in stead of a dll or COM server, why not just write an executable and start it from my c# code. I can pass any start-up requirements as command line parameters . I would not have any problems with state management.

I could communicate with the process using any of the Interprocess communication options that are available (http://msdn.microsoft.com/en-us/library/aa365574(v=vs.85).aspx <http://msdn.microsoft.com/en-us/library/aa365574%28v=vs.85%29.aspx>)

The easiest would be just to use TCP based socket connection. The Delphi executable would be the server and my C# code the client.

The only issue is what service port to use. While one could have that has a configurable item many clients aren't that savvy and I have no control over what other software they install and use. I though that I could generate one randomly in the same way one is allocated during asp.net development.

After googling I found this code that enabled me to determine what ports are being listened to locally.

                IPGlobalProperties  ipGlobalProperties 
=IPGlobalProperties.GetIPGlobalProperties();
                IPEndPoint[] tcpConnInfoArray = 
ipGlobalProperties.GetActiveTcpListeners();

                foreach  (IPEndPoint  endpointin  tcpConnInfoArray)
                {
                        Console.WriteLine(String.Format("Port {0} - 
{1}",endpoint.Port,endpoint.Address));
                }

I know that another executable or service could be started after my port scan 
and use it
but then my socket server would fail to start.

Does this sound reasonable or is there a better way.  I am not sure how the 
port is allocated during asp.net development if this code was available
then I could plagiarise that.




Reply via email to