コード例 #1
0
ファイル: HttpServer.cs プロジェクト: yizhang82/corefxlab
        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;
                }
            }
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: HttpServer.cs プロジェクト: ericl85/Channels
        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;
                }
            }
        }