Ejemplo n.º 1
0
        private void StartAcceptingRIOConnections <TContext>(IHttpApplication <TContext> application, IPAddress ip, int port)
        {
            Thread.CurrentThread.Name = "RIO Accept Thread";
            var addressBytes = ip.GetAddressBytes();

            try
            {
                _rioTcpServer = new RioTcpServer((ushort)port, addressBytes[0], addressBytes[1], addressBytes[2], addressBytes[3]);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            while (true)
            {
                try
                {
                    var connection = _rioTcpServer.Accept();
                    var task       = ProcessRIOConnection(application, connection);
                }
                catch (ObjectDisposedException)
                {
                    break;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            _rioTcpServer?.Stop();
            _listenSocket?.Dispose();
            _uvTcpListener?.Dispose();
            _uvThread?.Dispose();

            _rioTcpServer  = null;
            _listenSocket  = null;
            _uvTcpListener = null;
            _uvThread      = null;
        }
Ejemplo n.º 3
0
        protected override Task Start(IPEndPoint ipEndpoint)
        {
            var bytes = ipEndpoint.Address.GetAddressBytes();

            listener    = new RioTcpServer((ushort)ipEndpoint.Port, bytes[0], bytes[1], bytes[2], bytes[3]);
            runningtask = Task.Run(() =>
            {
                while (running)
                {
                    var socket = listener.Accept();
                    var task   = ProcessConnection(socket);
                }
            });

            return(Task.CompletedTask);
        }
Ejemplo n.º 4
0
        private void StartAcceptingRIOConnections <TContext>(IHttpApplication <TContext> application, IPAddress ip, int port)
        {
            var addressBytes = ip.GetAddressBytes();

            _rioTcpServer = new RioTcpServer((ushort)port, addressBytes[0], addressBytes[1], addressBytes[2], addressBytes[3]);

            while (true)
            {
                try
                {
                    var connection = _rioTcpServer.Accept();
                    var task       = Task.Factory.StartNew(() => ProcessRIOConnection(application, connection));
                }
                catch (ObjectDisposedException)
                {
                    break;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    break;
                }
            }
        }
Ejemplo n.º 5
0
 public void Dispose()
 {
     _rioTcpServer?.Stop();
     _rioTcpServer = null;
 }