本文整理汇总了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);
}
示例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;
}
}
}
}