Beispiel #1
0
        private static void reader_Initialize(object sender, EventArgs e)
        {
            //HELPER VARIABLES
            bool   success = false;
            string host    = "127.0.0.1";
            int    port    = 0;

            //GET THE NETWORK SETTINGS
            NetworkSettings section = (NetworkSettings)ConfigurationManager.GetSection("Saga.NetworkSettings");

            if (section != null)
            {
                NetworkElement Element = section.Connections["public"];
                if (Element != null)
                {
                    host = Element.Host;
                    port = Element.Port;
                }
            }

            while (success == false)
            {
                try
                {
                    //START LISTENING TO NETWORK
                    networkManger = new EncryptedManager <GatewayClient>(host, port);
                    networkManger.Start();
                    success = true;
                    Console.WriteLine("Accepting connections from: {0}:{1}", host, port);
                }
                catch (SocketException ex)
                {
                    if (ex.ErrorCode == 10049)
                    {
                        Trace.TraceError("The ip adress {0}:{1} is not an local ip adress", host, port);
                        Console.WriteLine("The ip adress {0}:{1} is not an local ip adress", host, port);
                        Thread.Sleep(60000);
                    }
                    else if (ex.ErrorCode == 10048)
                    {
                        Trace.TraceError("The port number is already in use: {0}:{1}", host, port);
                        Console.WriteLine("The port number is already in use: {0}:{1}", host, port);
                        Thread.Sleep(60000);
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (FormatException)
                {
                    Trace.TraceError("The ip adress {0}:{1} is invalid formatted", host, port);
                    Console.WriteLine("The ip adress {0}:{1} is invalid formatted", host, port);
                    Thread.Sleep(60000);
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.Message);
                    Thread.Sleep(60000);
                }
            }
        }
Beispiel #2
0
        private static void reader_Initialize(object sender, EventArgs e)
        {
            //HELPER VARIABLES
            bool success = false;
            string host = "127.0.0.1";
            int port = 0;

            //GET THE NETWORK SETTINGS
            NetworkSettings section = (NetworkSettings)ConfigurationManager.GetSection("Saga.NetworkSettings");
            if (section != null)
            {
                NetworkElement Element = section.Connections["public"];
                if (Element != null)
                {
                    host = Element.Host;
                    port = Element.Port;
                }
            }

            while (success == false)
            {
                try
                {
                    //START LISTENING TO NETWORK
                    networkManger = new EncryptedManager<GatewayClient>(host, port);
                    networkManger.Start();
                    success = true;
                    Console.WriteLine("Accepting connections from: {0}:{1}", host, port);
                }
                catch (SocketException ex)
                {
                    if (ex.ErrorCode == 10049)
                    {
                        Trace.TraceError("The ip adress {0}:{1} is not an local ip adress", host, port);
                        Console.WriteLine("The ip adress {0}:{1} is not an local ip adress", host, port);
                        Thread.Sleep(60000);
                    }
                    else if (ex.ErrorCode == 10048)
                    {
                        Trace.TraceError("The port number is already in use: {0}:{1}", host, port);
                        Console.WriteLine("The port number is already in use: {0}:{1}", host, port);
                        Thread.Sleep(60000);
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (FormatException)
                {
                    Trace.TraceError("The ip adress {0}:{1} is invalid formatted", host, port);
                    Console.WriteLine("The ip adress {0}:{1} is invalid formatted", host, port);
                    Thread.Sleep(60000);
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.Message);
                    Thread.Sleep(60000);
                }
            }
        }