当前位置: 首页>>代码示例>>C#>>正文


C# SocketBase.Send方法代码示例

本文整理汇总了C#中NetMQ.zmq.SocketBase.Send方法的典型用法代码示例。如果您正苦于以下问题:C# SocketBase.Send方法的具体用法?C# SocketBase.Send怎么用?C# SocketBase.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetMQ.zmq.SocketBase的用法示例。


在下文中一共展示了SocketBase.Send方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendMsg

 private static void SendMsg(SocketBase s, Msg msg, SendReceiveOptions flags)
 {
     s.Send(msg, flags);
 }
开发者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

示例3: SendMsg

 private static int SendMsg(SocketBase s, Msg msg, SendRecieveOptions flags)
 {
     int sz = MsgSize(msg);
     bool rc = s.Send(msg, flags);
     if (!rc)
         return -1;
     return sz;
 }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:8,代码来源:ZMQ.cs

示例4: Write

        public void Write(SocketBase s)
        {
            int size = 4 + 1 + m_addr.Length + 1; // event + len(addr) + addr + flag
            if (m_flag == ValueInteger)
              size += 4;
            else if (m_flag == ValueChannel)
            {
                size += SizeOfIntPtr;
            }

            int pos = 0;

            ByteArraySegment buffer = new byte[size];
            buffer.PutInteger(Endianness.Little,  (int)m_monitorEvent, pos);
            pos += 4;
            buffer[pos++] = (byte)m_addr.Length;

            // was not here originally

            buffer.PutString(m_addr, pos);
            pos += m_addr.Length;

            buffer[pos++] = ((byte)m_flag);
            if (m_flag == ValueInteger)
            {
                buffer.PutInteger(Endianness.Little, (int)m_arg, pos);
            }
            else if (m_flag == ValueChannel)
            {
                GCHandle handle = GCHandle.Alloc(m_arg, GCHandleType.Weak);

                if (SizeOfIntPtr == 4)
                {
                    buffer.PutInteger(Endianness.Little, GCHandle.ToIntPtr(handle).ToInt32(), pos);
                }
                else
                {
                    buffer.PutLong(Endianness.Little, GCHandle.ToIntPtr(handle).ToInt64(), pos);
                }
            }

            Msg msg = new Msg((byte[])buffer);
            s.Send(msg, 0);
        }
开发者ID:GianniBortoloBossini,项目名称:netmq,代码行数:44,代码来源:MonitorEvent.cs

示例5: Write

        public bool Write(SocketBase s)
        {
            int size = 4 + 1 + m_addr.Length + 1; // event + len(addr) + addr + flag
            if (m_flag == ValueInteger)
              size += 4;
            else if (m_flag == ValueChannel)
            {
                size += SizeOfIntPtr;
            }

            int pos = 0;

            ByteArraySegment buffer = new byte[size];
            buffer.PutInteger((int)m_monitorEvent, pos);
            pos += 4;
            buffer[pos++] = (byte)m_addr.Length;

            // was not here originally

            buffer.PutString(m_addr, pos);
            pos += m_addr.Length;

            buffer[pos++] = ((byte)m_flag);
            if (m_flag == ValueInteger)
            {
                buffer.PutInteger((int) m_arg, pos);
            }
            else if (m_flag == ValueChannel)
            {
                if (SizeOfIntPtr == 4)
                {
                    buffer.PutInteger(((Socket)m_arg).Handle.ToInt32(), pos);
                }
                else
                {
                    buffer.PutLong(((Socket)m_arg).Handle.ToInt64(), pos);
                }
            }

            Msg msg = new Msg((byte[])buffer);
            return s.Send(msg, 0);
        }
开发者ID:oskarwkarlsson,项目名称:netmq,代码行数:42,代码来源:MonitorEvent.cs


注:本文中的NetMQ.zmq.SocketBase.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。