久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

Thrift第七課C#語言測(cè)試C++服務(wù)器

場(chǎng)景

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信平臺(tái)小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了響水免費(fèi)建站歡迎大家使用!

目前通過Thrift框架生成了C#代碼,由于沒有怎么接觸過這門語言,因此直接啟動(dòng)程序模擬多個(gè)用戶進(jìn)行測(cè)試。在無法修改代碼進(jìn)行負(fù)載性測(cè)試的情況下,可以使用system函數(shù)啟動(dòng)程序,模擬多個(gè)用戶的實(shí)際操作。

#include <windows.h>

int main()

{

while (1)

{

::system("E:/thriftserver/thrift-csharp/ThriftTest/bin/Debug/ThriftTest.exe");

::Sleep(1000);

}

return 0;

}

C#的實(shí)際代碼如下

       static void ProcessThread(TProtocol protocol)

        {

            TProcessor processor = new PushMessageService.Processor(new CRecvMessageSErviceImpl());

            while (true)

            {

                try

                {

                    while (processor.Process(protocol, protocol)) { };

                    return;

                }

                catch (System.NullReferenceException tt)

                {

                    return;

                }

                catch (Thrift.Transport.TTransportException tt)

                {

                    //服務(wù)器沒有啟動(dòng),會(huì)拋出此異常

                    return;

                }

            }

        }

        static void MonitorThread(TTransport trans, Action<string> callback)

        {

            while (true)

            {

                try

                {

                    if (!trans.Peek())

                    {

                        callback("connect close\n");

                    }

                    Thread.Sleep(200);

                }

                catch (Thrift.TApplicationException ex)

                {

                    callback(ex.Message);

                    return;

                }

            }

        }

        static void Main(string[] args)

        {

            TTransport transport = new TBufferedTransport(new TSocket("192.168.1.110", 7001));

            TProtocol protocol = new TBinaryProtocol(transport);

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

            Action<TProtocol> processAction = new Action<TProtocol>(ProcessThread);

            Action<TTransport, Action<string>> monitorAction = new Action<TTransport, Action<string>>(MonitorThread);

            try

            {

                transport.Open();

                processAction.BeginInvoke(protocol, (result) =>

                {

                    processAction.EndInvoke(result);

                }, null);

                monitorAction.BeginInvoke(transport, (msg) =>

                {

                    Console.WriteLine("connect stop", msg);

                }, (result) =>

                {

                }, null);

                info.StrUserId = "admin";

                info.StrPassword = "admin";

                client.Login(info);

                }

            }

            catch (System.NullReferenceException  ttx)

            {

                //服務(wù)器停止運(yùn)行,會(huì)拋出此異常

                return;

            }

            catch (System.IO.IOException ttx)

            {

                return;

            }

            catch (Thrift.Transport.TTransportException tt)

            {

                //服務(wù)器沒有啟動(dòng),會(huì)拋出此異常

                return;

            }

            //transport.Close();

//在這里模擬異常情況,沒有正常關(guān)閉

        }

    }

分享標(biāo)題:Thrift第七課C#語言測(cè)試C++服務(wù)器
文章鏈接:http://sd-ha.com/article20/jisoco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、微信公眾號(hào)外貿(mào)建站、動(dòng)態(tài)網(wǎng)站、網(wǎng)站制作、Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)