Example #1
0
        /// <summary>
        /// 数据包输入
        /// </summary>
        /// <param name="data">输入数据</param>
        /// <param name="socketAsync">该数据包的通讯SOCKET</param>
        static async void BinaryInputHandler(ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw <string>();

            fiberRw.UserToken = "my is ttk";

            for (; ;)
            {
                try
                {
                    await DataOnByLine(fiberRw);
                }
                catch (System.Net.Sockets.SocketException)
                {
                    break;
                }
                catch (Exception er)
                {
                    Console.WriteLine(er.ToString());
                    break;
                }
            }

            socketAsync.Disconnect();
        }
Example #2
0
        private static async void Client_BinaryInput(ISocketClient client, ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw();

            client.SetConnected();

            while (true)
            {
                try
                {
                    //var data = await fiberRw.ReadToBlockArrayEnd();
                    //WriteBytes writeBytes = new WriteBytes(fiberRw);
                    //writeBytes.Write(data);
                    //await writeBytes.AwaitFlush();

                    await DataOnByLine(fiberRw);

                    Console.WriteLine("OK");
                }
                catch
                {
                    break;
                }
            }


            client.ShutdownBoth(true);
        }
Example #3
0
        /// <summary>
        /// 数据包输入
        /// </summary>
        /// <param name="data">输入数据</param>
        /// <param name="socketAsync">该数据包的通讯SOCKET</param>
        static async void BinaryInputHandler(ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw <string>();

            fiberRw.UserToken = "my is ttk";

            for (; ;)
            {
                try
                {
                    //读取 发送 测试
                    var data = await fiberRw.ReadToBlockArrayEnd();

                    fiberRw.Write(data);
                    await fiberRw.FlushAsync();
                }
                catch (SocketException)
                {
                    break;
                }
                catch (Exception er)
                {
                    Console.WriteLine(er.ToString());
                    break;
                }

                //try
                //{
                //    //提供2种数据 读取写入方式
                //    using (ReadBytes readBytes = new ReadBytes(fiberRw))
                //    {
                //        await readBytes.Init();
                //        DataOn(readBytes, fiberRw);
                //    }


                //    await DataOnByLine(fiberRw);



                //}
                //catch (System.Net.Sockets.SocketException)
                //{
                //    break;
                //}
                //catch (Exception er)
                //{
                //    Console.WriteLine(er.ToString());
                //    break;
                //}
            }

            socketAsync.Disconnect();
        }
Example #4
0
        async void BinaryInputHandler(ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw <HttpToken>();

            fiberRw.UserToken = new HttpToken();

            using (var data_r = fiberRw.GetMemory(4096))
                using (var data_w = fiberRw.GetMemory(4096))
                {
                    for (; ;)
                    {
                        await HttpHandler.Receive(fiberRw, data_r.Memory, data_w.Memory);
                    }
                }
        }
        async void BinaryInputHandler(ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw <HttpToken>();

            fiberRw.UserToken = new HttpToken
            {
                Db = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance)
            };

            using var data_r = fiberRw.GetMemory(1024);
            using var write  = new WriteBytes(fiberRw);
            for (; ;)
            {
                await HttpHandler.Receive(fiberRw, data_r.Memory, write);
            }
        }
        async void BinaryInputHandler(ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw <HttpToken>();

            fiberRw.UserToken = new HttpToken
            {
                Db = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance)
            };



            using (var data_r = fiberRw.GetMemory(4096))
                using (var data_w = fiberRw.GetMemory(16384))
                {
                    for (; ;)
                    {
                        await HttpHandler.Receive(fiberRw, data_r.Memory, data_w.Memory);
                    }
                }
        }
Example #7
0
        private static async void Client_BinaryInput(ISocketClient client, ISockAsyncEvent socketAsync)
        {
            var fiberRw = await socketAsync.GetFiberRw();

            client.SetConnected();

            while (true)
            {
                try
                {
                    await DataOnByLine(fiberRw);
                }
                catch
                {
                    break;
                }
            }


            client.ShutdownBoth(true);
        }