protected override void XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.Subscribe && option != ZmqSocketOptions.Unsubscribe) { throw InvalidException.Create(); } byte[] val; if (optval is String) val = Encoding.ASCII.GetBytes ((String)optval); else if (optval is byte[]) val = (byte[]) optval; else throw InvalidException.Create(); // Create the subscription message. Msg msg = new Msg(val.Length + 1); if (option == ZmqSocketOptions.Subscribe) msg.Put((byte)1); else if (option == ZmqSocketOptions.Unsubscribe) msg.Put((byte)0); msg.Put (val,1); // Pass it further on in the stack. base.XSend (msg, 0); }
protected override bool XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.Subscribe && option != ZmqSocketOptions.Unsubscribe) { ZError.ErrorNumber = (ErrorNumber.EINVAL); return false; } byte[] val; if (optval is String) val = Encoding.ASCII.GetBytes ((String)optval); else if (optval is byte[]) val = (byte[]) optval; else throw new ArgumentException(); // Create the subscription message. Msg msg = new Msg(val.Length + 1); if (option == ZmqSocketOptions.Subscribe) msg.Put((byte)1); else if (option == ZmqSocketOptions.Unsubscribe) msg.Put((byte)0); msg.Put (val,1); // Pass it further on in the stack. bool rc = base.XSend (msg, 0); return rc; }
protected override bool XSetSocketOption(ZmqSocketOptions option, Object optionValue) { if (option != ZmqSocketOptions.Subscribe && option != ZmqSocketOptions.Unsubscribe) { return false; } byte[] val; if (optionValue is string) val = Encoding.ASCII.GetBytes((string)optionValue); else if (optionValue is byte[]) val = (byte[])optionValue; else throw new InvalidException(string.Format("In Sub.XSetSocketOption({0},{1}), optionValue must be either a string or a byte-array.", option, (optionValue == null ? "null" : optionValue.ToString()))); // Create the subscription message. var msg = new Msg(); msg.InitPool(val.Length + 1); if (option == ZmqSocketOptions.Subscribe) msg.Put(1); else if (option == ZmqSocketOptions.Unsubscribe) msg.Put(0); msg.Put(val, 1, val.Length); try { // Pass it further on in the stack. bool isMessageSent = base.XSend(ref msg); if (!isMessageSent) { string xMsg = string.Format("in Sub.XSetSocketOption({0}, {1}), XSend returned false.", option, optionValue); throw new AgainException(innerException: null, message: xMsg); } } finally { msg.Close(); } return true; }
// The default implementation assumes there are no specific socket // options for the particular socket type. If not so, overload this // method. protected virtual bool XSetSocketOption(ZmqSocketOptions option, Object optval) { ZError.ErrorNumber = (ErrorNumber.EINVAL); return false; }
public static Object GetSocketOptionX(SocketBase s, ZmqSocketOptions option) { if (s == null || !s.CheckTag()) { throw NetMQException.Create(ErrorCode.EFAULT); } return s.GetSocketOptionX(option); }
/// <summary> /// Get the value of the specified option. /// </summary> /// <param name="option">a ZmqSocketOptions that specifies what to get</param> /// <returns>an Object that is the value of that option</returns> public Object GetSocketOption(ZmqSocketOptions option) { switch (option) { case ZmqSocketOptions.SendHighWatermark: return(SendHighWatermark); case ZmqSocketOptions.ReceiveHighWatermark: return(ReceiveHighWatermark); case ZmqSocketOptions.Affinity: return(Affinity); case ZmqSocketOptions.Identity: return(Identity); case ZmqSocketOptions.Rate: return(Rate); case ZmqSocketOptions.RecoveryIvl: return(RecoveryIvl); case ZmqSocketOptions.SendBuffer: return(SendBuffer); case ZmqSocketOptions.ReceiveBuffer: return(ReceiveBuffer); case ZmqSocketOptions.Type: return(SocketType); case ZmqSocketOptions.Linger: return(Linger); case ZmqSocketOptions.ReconnectIvl: return(ReconnectIvl); case ZmqSocketOptions.ReconnectIvlMax: return(ReconnectIvlMax); case ZmqSocketOptions.Backlog: return(Backlog); case ZmqSocketOptions.Maxmsgsize: return(MaxMessageSize); case ZmqSocketOptions.MulticastHops: return(MulticastHops); case ZmqSocketOptions.ReceiveTimeout: return(ReceiveTimeout); case ZmqSocketOptions.SendTimeout: return(SendTimeout); case ZmqSocketOptions.IPv4Only: return(IPv4Only); case ZmqSocketOptions.TcpKeepalive: return(TcpKeepalive); case ZmqSocketOptions.DelayAttachOnConnect: return(DelayAttachOnConnect); case ZmqSocketOptions.TcpKeepaliveIdle: return(TcpKeepaliveIdle); case ZmqSocketOptions.TcpKeepaliveIntvl: return(TcpKeepaliveIntvl); case ZmqSocketOptions.LastEndpoint: return(LastEndpoint); case ZmqSocketOptions.Endian: return(Endian); default: throw new InvalidException("GetSocketOption called with invalid ZmqSocketOptions of " + option); } }
protected override bool XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.RouterMandatory) { ZError.ErrorNumber = (ErrorNumber.EINVAL); return false; } m_mandatory = (int) optval == 1; return true; }
public void SetSocketOption(ZmqSocketOptions option, Object optval) { switch (option) { case ZmqSocketOptions.SendHighWatermark: SendHighWatermark = (int) optval; break; case ZmqSocketOptions.ReceivevHighWatermark: ReceiveHighWatermark = (int) optval; break; case ZmqSocketOptions.Affinity: Affinity = (long) optval; break; case ZmqSocketOptions.Identity: byte[] val; if (optval is String) val = Encoding.ASCII.GetBytes((String) optval); else if (optval is byte[]) val = (byte[]) optval; else { throw InvalidException.Create(); } if (val.Length ==0 || val.Length > 255) { throw InvalidException.Create(); } Identity = new byte[val.Length]; val.CopyTo(Identity, 0); IdentitySize = (byte) Identity.Length; break; case ZmqSocketOptions.Rate: Rate = (int) optval; break; case ZmqSocketOptions.RecoveryIvl: RecoveryIvl = (int) optval; break; case ZmqSocketOptions.SendBuffer: SendBuffer = (int) optval; break; case ZmqSocketOptions.ReceivevBuffer: ReceiveBuffer = (int) optval; break; case ZmqSocketOptions.Linger: Linger = (int) optval; break; case ZmqSocketOptions.ReconnectIvl: ReconnectIvl = (int) optval; if (ReconnectIvl < -1) { throw InvalidException.Create(); } break; case ZmqSocketOptions.ReconnectIvlMax: ReconnectIvlMax = (int) optval; if (ReconnectIvlMax < 0) { throw InvalidException.Create(); } break; case ZmqSocketOptions.Backlog: Backlog = (int) optval; break; case ZmqSocketOptions.Maxmsgsize: Maxmsgsize = (long) optval; break; case ZmqSocketOptions.MulticastHops: MulticastHops = (int) optval; break; case ZmqSocketOptions.ReceiveTimeout: ReceiveTimeout = (int) optval; break; case ZmqSocketOptions.SendTimeout: SendTimeout = (int) optval; break; case ZmqSocketOptions.IPv4Only: IPv4Only = (bool)optval; break; case ZmqSocketOptions.TcpKeepalive: TcpKeepalive = (int) optval; if (TcpKeepalive != -1 && TcpKeepalive != 0 && TcpKeepalive != 1) { throw InvalidException.Create(); } break; case ZmqSocketOptions.DelayAttachOnConnect: DelayAttachOnConnect = (bool) optval; break; case ZmqSocketOptions.TcpKeepaliveCnt: // not supported break; case ZmqSocketOptions.TcpKeepaliveIdle: TcpKeepaliveIdle = (int) optval; break; case ZmqSocketOptions.TcpKeepaliveIntvl: TcpKeepaliveIntvl = (int) optval; break; case ZmqSocketOptions.TcpAcceptFilter: String filterStr = (String) optval; if (filterStr == null) { TcpAcceptFilters.Clear(); } else if (filterStr.Length == 0 || filterStr.Length > 255) { throw InvalidException.Create(); } else { TcpAddress.TcpAddressMask filter = new TcpAddress.TcpAddressMask(); filter.Resolve(filterStr, IPv4Only); TcpAcceptFilters.Add(filter); } break; default: throw InvalidException.Create(); } }
public void SetSocketOption(ZmqSocketOptions option, Object optval) { if (m_ctxTerminated) { throw TerminatingException.Create(); } // First, check whether specific socket type overloads the option. try { XSetSocketOption(option, optval); return; } catch (InvalidException) { } // If the socket type doesn't support the option, pass it to // the generic option parser. m_options.SetSocketOption(option, optval); }
// The default implementation assumes there are no specific socket // options for the particular socket type. If not so, overload this // method. protected virtual void XSetSocketOption(ZmqSocketOptions option, Object optval) { throw InvalidException.Create(); }
public bool SetSocketOption(ZmqSocketOptions option, Object optval) { if (m_ctxTerminated) { ZError.ErrorNumber = ErrorNumber.ETERM; return false; } // First, check whether specific socket type overloads the option. bool rc = XSetSocketOption(option, optval); if (rc || !ZError.IsError(ErrorNumber.EINVAL)) return false; // If the socket type doesn't support the option, pass it to // the generic option parser. ZError.Clear(); return m_options.SetSocketOption(option, optval); }
public int GetSocketOption(ZmqSocketOptions option) { if (m_ctxTerminated) { throw TerminatingException.Create(); } if (option == ZmqSocketOptions.ReceiveMore) { return m_rcvMore ? 1 : 0; } if (option == ZmqSocketOptions.Events) { try { ProcessCommands(0, false); } catch (NetMQException ex) { if (ex.ErrorCode == ErrorCode.EINTR || ex.ErrorCode == ErrorCode.ETERM) { return -1; } else { Debug.Assert(false); throw; } } PollEvents val = 0; if (HasOut()) val |= PollEvents.PollOut; if (HasIn()) val |= PollEvents.PollIn; return (int)val; } return (int)GetSocketOptionX(option); }
protected override bool XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.XpubVerbose) { ZError.ErrorNumber = (ErrorNumber.EINVAL); return false; } m_verbose = (int) optval == 1; return true; }
public int GetSocketOption(ZmqSocketOptions option) { if (m_ctxTerminated) { ZError.ErrorNumber = (ErrorNumber.ETERM); return -1; } if (option == ZmqSocketOptions.ReceiveMore) { return m_rcvMore ? 1 : 0; } if (option == ZmqSocketOptions.Events) { bool rc = ProcessCommands(0, false); if (!rc && (ZError.IsError(ErrorNumber.EINTR) || ZError.IsError(ErrorNumber.ETERM))) return -1; Debug.Assert(rc); PollEvents val = 0; if (HasOut()) val |= PollEvents.PollOut; if (HasIn()) val |= PollEvents.PollIn; return (int)val; } return (int)GetSocketOptionX(option); }
/// <summary> /// Assign the given optionValue to the specified option. /// </summary> /// <param name="option">a ZmqSocketOptions that specifies what to set</param> /// <param name="optionValue">an Object that is the value to set that option to</param> public void SetSocketOption(ZmqSocketOptions option, Object optionValue) { switch (option) { case ZmqSocketOptions.SendHighWatermark: SendHighWatermark = (int)optionValue; break; case ZmqSocketOptions.ReceiveHighWatermark: ReceiveHighWatermark = (int)optionValue; break; case ZmqSocketOptions.Affinity: Affinity = (long)optionValue; break; case ZmqSocketOptions.Identity: byte[] val; if (optionValue is string) val = Encoding.ASCII.GetBytes((string)optionValue); else if (optionValue is byte[]) val = (byte[])optionValue; else { string xMsg = string.Format("In Options.SetSocketOption(Identity, {0}) optionValue must be a string or byte-array.", optionValue == null ? "null" : optionValue.ToString()); throw new InvalidException(xMsg); } if (val.Length == 0 || val.Length > 255) { string xMsg = string.Format("In Options.SetSocketOption(Identity,) optionValue yielded a byte-array of length {0}, should be 1..255.", val.Length); throw new InvalidException(xMsg); } Identity = new byte[val.Length]; val.CopyTo(Identity, 0); IdentitySize = (byte)Identity.Length; break; case ZmqSocketOptions.Rate: Rate = (int)optionValue; break; case ZmqSocketOptions.RecoveryIvl: RecoveryIvl = (int)optionValue; break; case ZmqSocketOptions.SendBuffer: SendBuffer = (int)optionValue; break; case ZmqSocketOptions.ReceiveBuffer: ReceiveBuffer = (int)optionValue; break; case ZmqSocketOptions.Linger: Linger = (int)optionValue; break; case ZmqSocketOptions.ReconnectIvl: ReconnectIvl = (int)optionValue; if (ReconnectIvl < -1) { throw new InvalidException(string.Format("Options.SetSocketOption(ReconnectIvl, {0}) optionValue must be >= -1.", ReconnectIvl)); } break; case ZmqSocketOptions.ReconnectIvlMax: ReconnectIvlMax = (int)optionValue; if (ReconnectIvlMax < 0) { throw new InvalidException(string.Format("Options.SetSocketOption(ReconnectIvlMax, {0}) optionValue must be non-negative.", ReconnectIvlMax)); } break; case ZmqSocketOptions.Backlog: Backlog = (int)optionValue; break; case ZmqSocketOptions.MaxMessageSize: MaxMessageSize = (long)optionValue; break; case ZmqSocketOptions.MulticastHops: MulticastHops = (int)optionValue; break; case ZmqSocketOptions.ReceiveTimeout: ReceiveTimeout = (int)optionValue; break; case ZmqSocketOptions.SendTimeout: SendTimeout = (int)optionValue; break; case ZmqSocketOptions.IPv4Only: IPv4Only = (bool)optionValue; break; case ZmqSocketOptions.TcpKeepalive: TcpKeepalive = (int)optionValue; if (TcpKeepalive != -1 && TcpKeepalive != 0 && TcpKeepalive != 1) { throw new InvalidException(string.Format("Options.SetSocketOption(TcpKeepalive, {0}) optionValue is neither -1, 0, nor 1.", TcpKeepalive)); } break; case ZmqSocketOptions.DelayAttachOnConnect: DelayAttachOnConnect = (bool)optionValue; break; case ZmqSocketOptions.TcpKeepaliveIdle: TcpKeepaliveIdle = (int)optionValue; break; case ZmqSocketOptions.TcpKeepaliveIntvl: TcpKeepaliveIntvl = (int)optionValue; break; case ZmqSocketOptions.TcpAcceptFilter: string filterStr = (string)optionValue; if (filterStr == null) { TcpAcceptFilters.Clear(); } else if (filterStr.Length == 0 || filterStr.Length > 255) { throw new InvalidException(string.Format("Options.SetSocketOption(TcpAcceptFilter,{0}), optionValue has invalid length of {1) but must be 1..255", filterStr, filterStr.Length)); } else { TcpAddress.TcpAddressMask filter = new TcpAddress.TcpAddressMask(); filter.Resolve(filterStr, IPv4Only); TcpAcceptFilters.Add(filter); } break; case ZmqSocketOptions.Endian: Endian = (Endianness)optionValue; break; default: throw new InvalidException("Options.SetSocketOption called with invalid ZmqSocketOptions of " + option); } }
/// <summary> /// Get the value of the specified option. /// </summary> /// <param name="option">a ZmqSocketOptions that specifies what to get</param> /// <returns>an Object that is the value of that option</returns> public Object GetSocketOption(ZmqSocketOptions option) { switch (option) { case ZmqSocketOptions.SendHighWatermark: return SendHighWatermark; case ZmqSocketOptions.ReceiveHighWatermark: return ReceiveHighWatermark; case ZmqSocketOptions.Affinity: return Affinity; case ZmqSocketOptions.Identity: return Identity; case ZmqSocketOptions.Rate: return Rate; case ZmqSocketOptions.RecoveryIvl: return RecoveryIvl; case ZmqSocketOptions.SendBuffer: return SendBuffer; case ZmqSocketOptions.ReceiveBuffer: return ReceiveBuffer; case ZmqSocketOptions.Type: return SocketType; case ZmqSocketOptions.Linger: return Linger; case ZmqSocketOptions.ReconnectIvl: return ReconnectIvl; case ZmqSocketOptions.ReconnectIvlMax: return ReconnectIvlMax; case ZmqSocketOptions.Backlog: return Backlog; case ZmqSocketOptions.MaxMessageSize: return MaxMessageSize; case ZmqSocketOptions.MulticastHops: return MulticastHops; case ZmqSocketOptions.ReceiveTimeout: return ReceiveTimeout; case ZmqSocketOptions.SendTimeout: return SendTimeout; case ZmqSocketOptions.IPv4Only: return IPv4Only; case ZmqSocketOptions.TcpKeepalive: return TcpKeepalive; case ZmqSocketOptions.DelayAttachOnConnect: return DelayAttachOnConnect; case ZmqSocketOptions.TcpKeepaliveIdle: return TcpKeepaliveIdle; case ZmqSocketOptions.TcpKeepaliveIntvl: return TcpKeepaliveIntvl; case ZmqSocketOptions.LastEndpoint: return LastEndpoint; case ZmqSocketOptions.Endian: return Endian; default: throw new InvalidException("GetSocketOption called with invalid ZmqSocketOptions of " + option); } }
protected override void XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.RouterMandatory) { throw InvalidException.Create(); } m_mandatory = (bool)optval; }
internal TimeSpan GetSocketOptionTimeSpan(ZmqSocketOptions socketOptions) { return(TimeSpan.FromMilliseconds(ZMQ.GetSocketOption(m_socketHandle, socketOptions))); }
internal int GetSocketOption(ZmqSocketOptions socketOptions) { return(ZMQ.GetSocketOption(m_socketHandle, socketOptions)); }
public Object GetSocketOptionX(ZmqSocketOptions option) { if (m_ctxTerminated) { ZError.ErrorNumber = (ErrorNumber.ETERM); return null; } if (option == ZmqSocketOptions.ReceiveMore) { return m_rcvMore ? 1 : 0; } if (option == ZmqSocketOptions.FD) { return m_mailbox.FD; } if (option == ZmqSocketOptions.Events) { bool rc = ProcessCommands(0, false); if (!rc && (ZError.IsError(ErrorNumber.EINTR) || ZError.IsError(ErrorNumber.ETERM))) return -1; Debug.Assert(rc); int val = 0; if (HasOut()) val |= ZMQ.ZmqPollout; if (HasIn()) val |= ZMQ.ZmqPollin; return val; } // If the socket type doesn't support the option, pass it to // the generic option parser. return m_options.GetSocketOption(option); }
protected override bool XSetSocketOption(ZmqSocketOptions option, Object optionValue) { if (option == ZmqSocketOptions.XpubVerbose) { m_verbose = (bool)optionValue; return true; } else if (option == ZmqSocketOptions.XPublisherManual) { m_manual = true; return true; } else if (option == ZmqSocketOptions.Subscribe && m_manual && m_lastPipe != null) { byte[] subscription; if (optionValue is byte[]) { subscription = optionValue as byte[]; } else { subscription = Encoding.ASCII.GetBytes((string)optionValue); } m_subscriptions.Add(subscription, 0, subscription.Length, m_lastPipe); return true; } else if (option == ZmqSocketOptions.Unsubscribe && m_manual && m_lastPipe != null) { byte[] subscription; if (optionValue is byte[]) { subscription = optionValue as byte[]; } else { subscription = Encoding.ASCII.GetBytes((string)optionValue); } m_subscriptions.Remove(subscription, 0, subscription.Length, m_lastPipe); return true; } else if (option == ZmqSocketOptions.XPublisherWelcomeMessage) { m_welcomeMessage.Close(); if (optionValue != null) { if (optionValue is byte[]) { var value = (byte[])optionValue; var welcomeBytes = new byte[value.Length]; value.CopyTo(welcomeBytes, 0); m_welcomeMessage.InitGC(welcomeBytes, welcomeBytes.Length); } else { throw new InvalidException(string.Format("In XPub.XSetSocketOption({0},{1}), optionValue must be a byte-array.", option, optionValue)); } } else { m_welcomeMessage.InitEmpty(); } return true; } return false; }
protected override void XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.RouterMandatory && option != ZmqSocketOptions.RouterRawSocket) { throw InvalidException.Create(); } if (option == ZmqSocketOptions.RouterRawSocket) { m_rawSocket = (bool)optval; if (m_rawSocket) { m_options.RecvIdentity = false; m_options.RawSocket = true; } } else { m_mandatory = (bool)optval; } }
public Object GetSocketOptionX(ZmqSocketOptions option) { if (m_ctxTerminated) { throw TerminatingException.Create(); } if (option == ZmqSocketOptions.ReceiveMore) { return m_rcvMore ? 1 : 0; } if (option == ZmqSocketOptions.FD) { return m_mailbox.FD; } if (option == ZmqSocketOptions.Events) { try { ProcessCommands(0, false); } catch (NetMQException ex) { Debug.Assert(false); if (ex.ErrorCode == ErrorCode.EINTR || ex.ErrorCode == ErrorCode.ETERM) { return -1; } else { throw; } } int val = 0; if (HasOut()) val |= ZMQ.ZmqPollout; if (HasIn()) val |= ZMQ.ZmqPollin; return val; } // If the socket type doesn't support the option, pass it to // the generic option parser. return m_options.GetSocketOption(option); }
/// <summary> /// The default implementation assumes there are no specific socket /// options for the particular socket type. If not so, overload this /// method. /// </summary> /// <param name="option">a ZmqSocketOptions specifying which option to set</param> /// <param name="optionValue">an Object that is the value to set the option to</param> protected virtual bool XSetSocketOption(ZmqSocketOptions option, [CanBeNull] Object optionValue) { return false; }
public int GetSocketOption(ZmqSocketOptions option) { CheckContextTerminated(); if (option == ZmqSocketOptions.ReceiveMore) { return m_rcvMore ? 1 : 0; } if (option == ZmqSocketOptions.Events) { try { ProcessCommands(0, false); } catch (TerminatingException) { return -1; } PollEvents val = 0; if (HasOut()) val |= PollEvents.PollOut; if (HasIn()) val |= PollEvents.PollIn; return (int)val; } return (int)GetSocketOptionX(option); }
public Object GetSocketOptionX(ZmqSocketOptions option) { CheckContextTerminated(); if (option == ZmqSocketOptions.ReceiveMore) { return m_rcvMore; } if (option == ZmqSocketOptions.Handle) { return m_mailbox.Handle; } if (option == ZmqSocketOptions.Events) { try { ProcessCommands(0, false); } catch (TerminatingException) { return -1; } PollEvents val = 0; if (HasOut()) val |= PollEvents.PollOut; if (HasIn()) val |= PollEvents.PollIn; return val; } // If the socket type doesn't support the option, pass it to // the generic option parser. return m_options.GetSocketOption(option); }
protected override void XSetSocketOption(ZmqSocketOptions option, Object optval) { if (option != ZmqSocketOptions.XpubVerbose) { throw InvalidException.Create(); } m_verbose = (int)optval == 1; }
public void SetSocketOption(ZmqSocketOptions option, Object optval) { CheckContextTerminated(); // First, check whether specific socket type overloads the option. if (!XSetSocketOption(option, optval)) { // If the socket type doesn't support the option, pass it to // the generic option parser. m_options.SetSocketOption(option, optval); } }
public Object GetSocketOption(ZmqSocketOptions option) { switch (option) { case ZmqSocketOptions.SendHighWatermark: return SendHighWatermark; case ZmqSocketOptions.ReceivevHighWatermark: return ReceiveHighWatermark; case ZmqSocketOptions.Affinity: return Affinity; case ZmqSocketOptions.Identity: return Identity; case ZmqSocketOptions.Rate: return Rate; case ZmqSocketOptions.RecoveryIvl: return RecoveryIvl; case ZmqSocketOptions.SendBuffer: return SendBuffer; case ZmqSocketOptions.ReceivevBuffer: return ReceiveBuffer; case ZmqSocketOptions.Type: return SocketType; case ZmqSocketOptions.Linger: return Linger; case ZmqSocketOptions.ReconnectIvl: return ReconnectIvl; case ZmqSocketOptions.ReconnectIvlMax: return ReconnectIvlMax; case ZmqSocketOptions.Backlog: return Backlog; case ZmqSocketOptions.Maxmsgsize: return Maxmsgsize; case ZmqSocketOptions.MulticastHops: return MulticastHops; case ZmqSocketOptions.ReceiveTimeout: return ReceiveTimeout; case ZmqSocketOptions.SendTimeout: return SendTimeout; case ZmqSocketOptions.IPv4Only: return IPv4Only; case ZmqSocketOptions.TcpKeepalive: return TcpKeepalive; case ZmqSocketOptions.DelayAttachOnConnect: return DelayAttachOnConnect; case ZmqSocketOptions.TcpKeepaliveCnt: // not supported return 0; case ZmqSocketOptions.TcpKeepaliveIdle: return TcpKeepaliveIdle; case ZmqSocketOptions.TcpKeepaliveIntvl: return TcpKeepaliveIntvl; case ZmqSocketOptions.LastEndpoint: return LastEndpoint; default: throw InvalidException.Create(); } }
public static Object GetSocketOptionX(SocketBase s, ZmqSocketOptions option) { if (s == null || !s.CheckTag()) { throw new InvalidOperationException(); } return s.GetSocketOptionX(option); }
public static int GetSocketOption(SocketBase s, ZmqSocketOptions opt) { return s.GetSocketOption(opt); }
public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval) { if (s == null || !s.CheckTag()) { throw new InvalidOperationException(); } s.SetSocketOption(option, optval); }
public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval) { if (s == null || !s.CheckTag()) { throw NetMQException.Create(ErrorCode.EFAULT); } s.SetSocketOption(option, optval); }
/// <summary> /// Assign the given optionValue to the specified option. /// </summary> /// <param name="option">a ZmqSocketOptions that specifies what to set</param> /// <param name="optionValue">an Object that is the value to set that option to</param> public void SetSocketOption(ZmqSocketOptions option, Object optionValue) { switch (option) { case ZmqSocketOptions.SendHighWatermark: SendHighWatermark = (int)optionValue; break; case ZmqSocketOptions.ReceiveHighWatermark: ReceiveHighWatermark = (int)optionValue; break; case ZmqSocketOptions.Affinity: Affinity = (long)optionValue; break; case ZmqSocketOptions.Identity: byte[] val; if (optionValue is String) { val = Encoding.ASCII.GetBytes((String)optionValue); } else if (optionValue is byte[]) { val = (byte[])optionValue; } else { String xMsg = String.Format("In Options.SetSocketOption(Identity, {0}) optionValue must be a String or byte-array.", optionValue == null ? "null" : optionValue.ToString()); throw new InvalidException(xMsg); } if (val.Length == 0 || val.Length > 255) { String xMsg = String.Format("In Options.SetSocketOption(Identity,) optionValue yielded a byte-array of length {0}, should be 1..255.", val.Length); throw new InvalidException(xMsg); } Identity = new byte[val.Length]; val.CopyTo(Identity, 0); IdentitySize = (byte)Identity.Length; break; case ZmqSocketOptions.Rate: Rate = (int)optionValue; break; case ZmqSocketOptions.RecoveryIvl: RecoveryIvl = (int)optionValue; break; case ZmqSocketOptions.SendBuffer: SendBuffer = (int)optionValue; break; case ZmqSocketOptions.ReceiveBuffer: ReceiveBuffer = (int)optionValue; break; case ZmqSocketOptions.Linger: Linger = (int)optionValue; break; case ZmqSocketOptions.ReconnectIvl: ReconnectIvl = (int)optionValue; if (ReconnectIvl < -1) { throw new InvalidException(String.Format("Options.SetSocketOption(ReconnectIvl, {0}) optionValue must be >= -1.", ReconnectIvl)); } break; case ZmqSocketOptions.ReconnectIvlMax: ReconnectIvlMax = (int)optionValue; if (ReconnectIvlMax < 0) { throw new InvalidException(String.Format("Options.SetSocketOption(ReconnectIvlMax, {0}) optionValue must be non-negative.", ReconnectIvlMax)); } break; case ZmqSocketOptions.Backlog: Backlog = (int)optionValue; break; case ZmqSocketOptions.Maxmsgsize: MaxMessageSize = (long)optionValue; break; case ZmqSocketOptions.MulticastHops: MulticastHops = (int)optionValue; break; case ZmqSocketOptions.ReceiveTimeout: ReceiveTimeout = (int)optionValue; break; case ZmqSocketOptions.SendTimeout: SendTimeout = (int)optionValue; break; case ZmqSocketOptions.IPv4Only: IPv4Only = (bool)optionValue; break; case ZmqSocketOptions.TcpKeepalive: TcpKeepalive = (int)optionValue; if (TcpKeepalive != -1 && TcpKeepalive != 0 && TcpKeepalive != 1) { throw new InvalidException(String.Format("Options.SetSocketOption(TcpKeepalive, {0}) optionValue is neither -1, 0, nor 1.", TcpKeepalive)); } break; case ZmqSocketOptions.DelayAttachOnConnect: DelayAttachOnConnect = (bool)optionValue; break; case ZmqSocketOptions.TcpKeepaliveIdle: TcpKeepaliveIdle = (int)optionValue; break; case ZmqSocketOptions.TcpKeepaliveIntvl: TcpKeepaliveIntvl = (int)optionValue; break; case ZmqSocketOptions.TcpAcceptFilter: String filterStr = (String)optionValue; if (filterStr == null) { TcpAcceptFilters.Clear(); } else if (filterStr.Length == 0 || filterStr.Length > 255) { throw new InvalidException(String.Format("Options.SetSocketOption(TcpAcceptFilter,{0}), optionValue has invalid length of {1) but must be 1..255", filterStr, filterStr.Length)); } else { TcpAddress.TcpAddressMask filter = new TcpAddress.TcpAddressMask(); filter.Resolve(filterStr, IPv4Only); TcpAcceptFilters.Add(filter); } break; case ZmqSocketOptions.Endian: Endian = (Endianness)optionValue; break; default: throw new InvalidException("Options.SetSocketOption called with invalid ZmqSocketOptions of " + option); } }