當前位置: 首頁>>代碼示例>>C#>>正文


C# SocketBase.GetSocketOption方法代碼示例

本文整理匯總了C#中NetMQ.zmq.SocketBase.GetSocketOption方法的典型用法代碼示例。如果您正苦於以下問題:C# SocketBase.GetSocketOption方法的具體用法?C# SocketBase.GetSocketOption怎麽用?C# SocketBase.GetSocketOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NetMQ.zmq.SocketBase的用法示例。


在下文中一共展示了SocketBase.GetSocketOption方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetSocketOption

 public static int GetSocketOption(SocketBase s, ZmqSocketOptions opt)
 {
     return s.GetSocketOption(opt);
 }
開發者ID:kamlesh-patel,項目名稱:netmq,代碼行數:4,代碼來源:ZMQ.cs

示例2: CreateProxy

        public static bool CreateProxy(SocketBase frontend,
                        SocketBase backend, SocketBase capture)
        {
            //  The algorithm below assumes ratio of requests and replies processed
            //  under full load to be 1:1.

            int more;
            int rc;
            Msg msg;
            PollItem[] items = new PollItem[2];

            items[0] = new PollItem(frontend, PollEvents.PollIn);
            items[1] = new PollItem(backend, PollEvents.PollIn);

            while (true)
            {
                //  Wait while there are either requests or replies to process.
                rc = ZMQ.Poll(items, -1);
                if (rc < 0)
                    return false;

                //  Process a request.
                if ((items[0].ResultEvent & PollEvents.PollIn) == PollEvents.PollIn)
                {
                    while (true)
                    {
                        try
                        {
                            msg = frontend.Recv(0);
                        }
                        catch (TerminatingException)
                        {
                            return false;
                        }

                        if (msg == null)
                        {
                            return false;
                        }

                        more = frontend.GetSocketOption(ZmqSocketOptions.ReceiveMore);

                        if (more < 0)
                            return false;

                        //  Copy message to capture socket if any
                        if (capture != null)
                        {
                            Msg ctrl = new Msg(msg);
                            capture.Send(ctrl, more > 0 ? SendReceiveOptions.SendMore : 0);
                        }

                        backend.Send(msg, more > 0 ? SendReceiveOptions.SendMore : 0);
                        if (more == 0)
                            break;
                    }
                }
                //  Process a reply.
                if ((items[1].ResultEvent & PollEvents.PollIn) == PollEvents.PollIn)
                {
                    while (true)
                    {
                        try
                        {
                            msg = backend.Recv(0);
                        }
                        catch (TerminatingException)
                        {
                            return false;
                        }

                        if (msg == null)
                        {
                            return false;
                        }

                        more = backend.GetSocketOption(ZmqSocketOptions.ReceiveMore);

                        if (more < 0)
                            return false;

                        //  Copy message to capture socket if any
                        if (capture != null)
                        {
                            Msg ctrl = new Msg(msg);
                            capture.Send(ctrl, more > 0 ? SendReceiveOptions.SendMore : 0);

                        }

                        frontend.Send(msg, more > 0 ? SendReceiveOptions.SendMore : 0);
                        if (more == 0)
                            break;
                    }
                }
            }
        }
開發者ID:jasenkin,項目名稱:netmq,代碼行數:96,代碼來源:Proxy.cs


注:本文中的NetMQ.zmq.SocketBase.GetSocketOption方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。