public static void  Main(System.String[] args)
		{
			if (args.Length < 1 || args.Length > 3)
			{
				System.Console.Out.WriteLine("Usage: HL7Server (shared_port | (locally_driven_port remotely_driven_port)) app_binding_URL");
				System.Environment.Exit(1);
			}
			
			NuGenSafeStorage storage = new NuGenNullSafeStorage();
			NuGenApplicationRouter router = new NuGenApplicationRouterImpl();
			
			try
			{
				NuGenHL7Server server = null;
				System.String appURL = null;
				if (args.Length == 2)
				{
					int port = System.Int32.Parse(args[0]);
					System.Net.Sockets.TcpListener temp_tcpListener;
					temp_tcpListener = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0], port);
					temp_tcpListener.Start();
					server = new NuGenHL7Server(temp_tcpListener, router, storage);
					appURL = args[1];
				}
				else
				{
					int localPort = System.Int32.Parse(args[0]);
					int remotePort = System.Int32.Parse(args[1]);
					System.Net.Sockets.TcpListener temp_tcpListener2;
					temp_tcpListener2 = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0], localPort);
					temp_tcpListener2.Start();
					System.Net.Sockets.TcpListener temp_tcpListener3;
					temp_tcpListener3 = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0], remotePort);
					temp_tcpListener3.Start();
					server = new NuGenHL7Server(temp_tcpListener2, temp_tcpListener3, router, storage);
					appURL = args[2];
				}
				
				NuGenApplicationLoader.loadApplications(router, getURL(appURL));
				
				server.start(null); //any address OK            
			}
			catch (System.FormatException)
			{
				System.Console.Out.WriteLine("Port arguments must be integers");
				System.Environment.Exit(2);
			}
			catch (System.IO.IOException e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
				System.Environment.Exit(3);
			}
			catch (NuGenHL7Exception e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
				System.Environment.Exit(4);
			}
			catch (System.UnauthorizedAccessException e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
				System.Environment.Exit(7);
			}
		}
Example #2
0
        public static void  Main(System.String[] args)
        {
            if (args.Length < 1 || args.Length > 3)
            {
                System.Console.Out.WriteLine("Usage: HL7Server (shared_port | (locally_driven_port remotely_driven_port)) app_binding_URL");
                System.Environment.Exit(1);
            }

            NuGenSafeStorage       storage = new NuGenNullSafeStorage();
            NuGenApplicationRouter router  = new NuGenApplicationRouterImpl();

            try
            {
                NuGenHL7Server server = null;
                System.String  appURL = null;
                if (args.Length == 2)
                {
                    int port = System.Int32.Parse(args[0]);
                    System.Net.Sockets.TcpListener temp_tcpListener;
                    temp_tcpListener = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0], port);
                    temp_tcpListener.Start();
                    server = new NuGenHL7Server(temp_tcpListener, router, storage);
                    appURL = args[1];
                }
                else
                {
                    int localPort  = System.Int32.Parse(args[0]);
                    int remotePort = System.Int32.Parse(args[1]);
                    System.Net.Sockets.TcpListener temp_tcpListener2;
                    temp_tcpListener2 = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0], localPort);
                    temp_tcpListener2.Start();
                    System.Net.Sockets.TcpListener temp_tcpListener3;
                    temp_tcpListener3 = new System.Net.Sockets.TcpListener(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0], remotePort);
                    temp_tcpListener3.Start();
                    server = new NuGenHL7Server(temp_tcpListener2, temp_tcpListener3, router, storage);
                    appURL = args[2];
                }

                NuGenApplicationLoader.loadApplications(router, getURL(appURL));

                server.start(null);                 //any address OK
            }
            catch (System.FormatException)
            {
                System.Console.Out.WriteLine("Port arguments must be integers");
                System.Environment.Exit(2);
            }
            catch (System.IO.IOException e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
                System.Environment.Exit(3);
            }
            catch (NuGenHL7Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
                System.Environment.Exit(4);
            }
            catch (System.UnauthorizedAccessException e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
                System.Environment.Exit(7);
            }
        }