Beispiel #1
0
        private static async void TryConnectTService()
        {
            var xService = new TService(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 0));
            var channel  = await xService.ConnectChannelAsync(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1234));

            if (channel != null)
            {
                Log.Info($"TryConnectTService Success: channelId={channel.Id}, thread={System.Threading.Thread.CurrentThread.ManagedThreadId}, ipEndPoint={((TChannel)channel).RemoteAddress}");

                for (int i = 0; i < 4; i++)
                {
                    var words = $"data={i}";
                    var data  = System.Text.Encoding.UTF8.GetBytes(words);
                    channel.Send(data);
                    Log.Info($"ConnectChannelAsync.Send: channelId={channel.Id}, thread={System.Threading.Thread.CurrentThread.ManagedThreadId}, {words}");
                }
            }
            else
            {
                Log.Error("TryConnectTService Error!!!");
            }
        }