Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            TTransport transport = new TSocket("localhost", 2221);
            TProtocol  protocol  = new TBinaryProtocol(transport);

            HelloService.Client client = new HelloService.Client(protocol);
            transport.Open();
            Console.WriteLine("Client calls .....");
            Console.WriteLine(client.hello("John"));
            Console.ReadLine();
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     try
     {
         //设置服务端端口号和地址
         TTransport transport = new TSocket("localhost", 8080);
         transport.Open();
         //设置传输协议为二进制传输协议
         TProtocol protocol = new TBinaryProtocol(transport);
         //创建客户端对象
         HelloService.Client client = new HelloService.Client(protocol);
         //调用服务端的方法
         Console.WriteLine(client.HelloString("HelloThrift"));
         Console.ReadKey();
     }
     catch (TTransportException e)
     {
         Console.WriteLine(e.Message);
     }
 }