public bool GetOption(ZSocketOption option, out UInt64 value) { Int64 resultValue; bool result = GetOption(option, out resultValue); value = (UInt64)resultValue; return(result); }
public byte[] GetOptionBytes(ZSocketOption option) { byte[] result; if (GetOption(option, out result)) { return(result); } return(null); }
public UInt64 GetOptionUInt64(ZSocketOption option) { UInt64 result; if (GetOption(option, out result)) { return(result); } return(default(UInt64)); }
public UInt32 GetOptionUInt32(ZSocketOption option) { UInt32 result; if (GetOption(option, out result)) { return(result); } return(default(UInt32)); }
public string GetOptionString(ZSocketOption option) { string result; if (GetOption(option, out result)) { return(result); } return(null); }
public bool SetOption(ZSocketOption option, Int64 value) { int optionLength = Marshal.SizeOf(typeof(Int64)); using (var optionValue = DispoIntPtr.Alloc(optionLength)) { Marshal.WriteInt64(optionValue, value); return(SetOption(option, optionValue.Ptr, optionLength)); } }
public bool SetOption(ZSocketOption option, string value) { if (value == null) { return(SetOptionNull(option)); } int optionLength; using (var optionValue = DispoIntPtr.AllocString(value, out optionLength)) { return(SetOption(option, optionValue, optionLength)); } }
private bool GetOption(ZSocketOption option, IntPtr optionValue, ref int optionLength) { EnsureNotDisposed(); using (var optionLengthP = DispoIntPtr.Alloc(IntPtr.Size)) { if (IntPtr.Size == 4) { Marshal.WriteInt32(optionLengthP.Ptr, optionLength); } else if (IntPtr.Size == 8) { Marshal.WriteInt64(optionLengthP.Ptr, (long)optionLength); } else { throw new PlatformNotSupportedException(); } ZError error; while (-1 == zmq.getsockopt(this._socketPtr, (int)option, optionValue, optionLengthP.Ptr)) { error = ZError.GetLastErr(); if (error == ZError.EINTR) { error = default(ZError); continue; } throw new ZException(error); } if (IntPtr.Size == 4) { optionLength = Marshal.ReadInt32(optionLengthP.Ptr); } else if (IntPtr.Size == 8) { optionLength = (int)Marshal.ReadInt64(optionLengthP.Ptr); } else { throw new PlatformNotSupportedException(); } } return(true); }
public bool SetOption(ZSocketOption option, byte[] value) { if (value == null) { return(SetOptionNull(option)); } int optionLength = /* Marshal.SizeOf(typeof(byte)) * */ value.Length; using (var optionValue = DispoIntPtr.Alloc(optionLength)) { Marshal.Copy(value, 0, optionValue.Ptr, optionLength); return(SetOption(option, optionValue.Ptr, optionLength)); } }
public bool GetOption(ZSocketOption option, out Int64 value) { value = default(Int64); int optionLength = Marshal.SizeOf(typeof(Int64)); using (var optionValue = DispoIntPtr.Alloc(optionLength)) { if (GetOption(option, optionValue.Ptr, ref optionLength)) { value = Marshal.ReadInt64(optionValue); return(true); } return(false); } }
public bool GetOption(ZSocketOption option, out string value) { value = null; int optionLength = MaxBinaryOptionSize; using (var optionValue = DispoIntPtr.Alloc(optionLength)) { if (GetOption(option, optionValue, ref optionLength)) { value = Marshal.PtrToStringAnsi(optionValue, optionLength); return(true); } return(false); } }
public bool GetOption(ZSocketOption option, out byte[] value) { value = null; int optionLength = MaxBinaryOptionSize; using (var optionValue = DispoIntPtr.Alloc(optionLength)) { if (GetOption(option, optionValue, ref optionLength)) { value = new byte[optionLength]; Marshal.Copy(optionValue, value, 0, optionLength); return(true); } return(false); } }
private bool SetOption(ZSocketOption option, IntPtr optionValue, int optionLength) { EnsureNotDisposed(); ZError error; while (-1 == zmq.setsockopt(this._socketPtr, (int)option, optionValue, optionLength)) { error = ZError.GetLastErr(); if (error == ZError.EINTR) { error = default(ZError); continue; } return(false); } return(true); }
public bool SetOptionNull(ZSocketOption option) { return(SetOption(option, IntPtr.Zero, 0)); }
public bool SetOption(ZSocketOption option, UInt64 value) { return(SetOption(option, (Int64)value)); }