当前位置: 首页>>代码示例>>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;未经允许,请勿转载。