本文整理汇总了C#中NetMQ.zmq.SocketBase.SetSocketOption方法的典型用法代码示例。如果您正苦于以下问题:C# SocketBase.SetSocketOption方法的具体用法?C# SocketBase.SetSocketOption怎么用?C# SocketBase.SetSocketOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetMQ.zmq.SocketBase
的用法示例。
在下文中一共展示了SocketBase.SetSocketOption方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSocketOption
public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
s.SetSocketOption(option, optval);
}
示例2: Monitor
public void Monitor(String addr, SocketEvent events)
{
if (m_ctxTerminated)
{
throw TerminatingException.Create();
}
// Support deregistering monitoring endpoints as well
if (addr == null)
{
StopMonitor();
return;
}
string address;
string protocol;
DecodeAddress(addr, out address, out protocol);
CheckProtocol(protocol);
// Event notification only supported over inproc://
if (!protocol.Equals(Address.InProcProtocol))
{
throw NetMQException.Create(ErrorCode.EPROTONOSUPPORT);
}
// Register events to monitor
m_monitorEvents = events;
m_monitorSocket = Ctx.CreateSocket(ZmqSocketType.Pair);
if (m_monitorSocket == null)
throw NetMQException.Create(ErrorCode.EFAULT);
// Never block context termination on pending event messages
int linger = 0;
try
{
m_monitorSocket.SetSocketOption(ZmqSocketOptions.Linger, linger);
}
catch (NetMQException)
{
StopMonitor();
throw;
}
// Spawn the monitor socket endpoint
try
{
m_monitorSocket.Bind(addr);
}
catch (NetMQException)
{
StopMonitor();
throw;
}
}
示例3: Monitor
public void Monitor([CanBeNull] string addr, SocketEvent events)
{
CheckContextTerminated();
// Support de-registering monitoring endpoints as well
if (addr == null)
{
StopMonitor();
return;
}
string address;
string protocol;
DecodeAddress(addr, out address, out protocol);
CheckProtocol(protocol);
// Event notification only supported over inproc://
if (!protocol.Equals(Address.InProcProtocol))
{
throw new ProtocolNotSupportedException(string.Format("In SocketBase.Monitor({0},), protocol must be inproc", addr));
}
// Register events to monitor
m_monitorEvents = events;
m_monitorSocket = Ctx.CreateSocket(ZmqSocketType.Pair);
if (m_monitorSocket == null)
throw new FaultException("In SocketBase.Monitor, Ctx.CreateSocket(ZmqSocketType.Pair) failed.");
// Never block context termination on pending event messages
const int linger = 0;
try
{
m_monitorSocket.SetSocketOption(ZmqSocketOptions.Linger, linger);
}
catch (NetMQException)
{
StopMonitor();
throw;
}
// Spawn the monitor socket endpoint
try
{
m_monitorSocket.Bind(addr);
}
catch (NetMQException)
{
StopMonitor();
throw;
}
}
示例4: Monitor
public bool Monitor(String addr, SocketEvent events)
{
bool rc;
if (m_ctxTerminated)
{
ZError.ErrorNumber = (ErrorNumber.ETERM);
return false;
}
// Support deregistering monitoring endpoints as well
if (addr == null)
{
StopMonitor();
return true;
}
// Parse addr_ string.
//Uri uri;
//try
//{
// uri = new Uri(addr);
//}
//catch (UriFormatException ex)
//{
// ZError.ErrorNumber = (ErrorNumber.EINVAL);
// throw new ArgumentException(addr, ex);
//}
//String protocol = uri.Scheme;
//String address = uri.Authority;
//String path = uri.AbsolutePath;
//if (string.IsNullOrEmpty(address))
// address = path;
string address;
string protocol;
DecodeAddress(addr, out address, out protocol);
CheckProtocol(protocol);
// Event notification only supported over inproc://
if (!protocol.Equals("inproc"))
{
ZError.ErrorNumber = (ErrorNumber.EPROTONOSUPPORT);
return false;
}
// Register events to monitor
m_monitorEvents = events;
m_monitorSocket = Ctx.CreateSocket(ZmqSocketType.Pair);
if (m_monitorSocket == null)
return false;
// Never block context termination on pending event messages
int linger = 0;
rc = m_monitorSocket.SetSocketOption(ZmqSocketOptions.Linger, linger);
if (!rc)
StopMonitor();
// Spawn the monitor socket endpoint
rc = m_monitorSocket.Bind(addr);
if (!rc)
StopMonitor();
return rc;
}
示例5: SetSocketOption
public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
{
if (s == null || !s.CheckTag())
{
throw new InvalidOperationException();
}
s.SetSocketOption(option, optval);
}