首页 新闻 会员 周边

thrift csharp client端 如何异步调用

0
悬赏园豆:100 [待解决问题]

thrift官网的内容基本都知道,但是关于csharp版的客户端异步调用服务器端,如何去做不是很清楚,有哪位大大知道的请指教一下

rabbit_liujch的主页 rabbit_liujch | 初学一级 | 园豆:102
提问于:2013-10-21 09:09
< >
分享
所有回答(1)
0

Server:

try

{

       CalculatorHandler handler = new CalculatorHandler();

       Calculator.Processor processor = new Calculator.Processor(handler);

       TServerTransport serverTransport = new TServerSocket(9090);

       TServer server = new TSimpleServer(processor, serverTransport);

       //server = new TThreadPoolServer(processor,serverTransport);

       Console.WriteLine("Starting the server...");

       server.Serve();

}

catch (Exception x)

{

       Console.WriteLine(x.StackTrace);

}

Console.WriteLine("done.");

Client:

try

{

    TTransport transport = new TSocket("localhost", 9090);

    TProtocol protocol = new TBinaryProtocol(transport);

    Calculator.Client client = new Calculator.Client(protocol);

 

    transport.Open();

    try

{

    //业务操作

        client.ping();

    }

    finally

    {

        transport.Close();

    }

}

catch (TApplicationException x)

{

    Console.WriteLine(x.StackTrace);

}

黑侠客 | 园豆:158 (初学一级) | 2013-10-25 18:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册