基本信息
源码名称:ThriftDemo实现客户端服务端通讯
源码大小:1.08M
文件格式:.zip
开发语言:C#
更新时间:2019-11-26
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 3 元 
   源码介绍
支持多客户端发送通信给服务端

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Thrift.Protocol;
using Thrift.Transport;

namespace Client
{
    class Program
    {
 
        static void Main(string[] args)
        {
            try
            {
                //var transport = new TSocket("localhost", 15789);
                var protocol = new TBinaryProtocol(transport);
                var client = new Common.ChatService.Client(protocol);
                transport.Open();

                ////测试一
                //Task.Run(() =>
                //{
                //    while (true)
                //    {
                //        Random m = new Random();
                //        int ronum = m.Next(10000);
                //        string words = ronum "说" DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //        string backMsg = ClientDo.GetServerData(words, client);
                //        Console.WriteLine(backMsg);
                //        Task.Delay(1000).Wait();
                //    }
                //});

                //测试二
                List<string> data = new List<string>();
                data.Add("每天吃饭");
                data.Add("每天看书");
                data.Add("每天跑步");
                List<string> list = client.GetList("小明", 66, data);
                Parallel.ForEach(list, m =>
                {
                    Console.WriteLine(m);
                });

                //transport.Close();

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine("发送数据失败:" ex.Message);
            }
            Console.ReadLine();
        }
 
    }
}