public int SetSocketOption(int option, byte[] value) { using (var optionValue = new DisposableIntPtr(value.Length)) { Marshal.Copy(value, 0, optionValue, value.Length); return(RetrySetSocketOptionIfInterrupted(option, optionValue.Ptr, value.Length)); } }
public int SetSocketOption(int option, int value) { using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(int)))) { Marshal.WriteInt32(optionValue, value); return(RetrySetSocketOptionIfInterrupted(option, optionValue.Ptr, sizeof(int))); } }
public int SetSocketOption(int option, ulong value) { using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(ulong)))) { Marshal.WriteInt64(optionValue, unchecked (Convert.ToInt64(value))); return(RetrySetSocketOptionIfInterrupted(option, optionValue.Ptr, sizeof(ulong))); } }
public int GetSocketOption(int option, out ulong value) { using (var optionLength = new DisposableIntPtr(IntPtr.Size)) using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(ulong)))) { Marshal.WriteInt32(optionLength, sizeof(ulong)); int rc = RetryGetSocketOptionIfInterrupted(option, optionValue.Ptr, optionLength.Ptr); value = unchecked (Convert.ToUInt64(Marshal.ReadInt64(optionValue))); return(rc); } }
public int GetSocketOption(int option, out string value) { using (var optionLength = new DisposableIntPtr(IntPtr.Size)) using (var optionValue = new DisposableIntPtr(MaxBinaryOptionSize)) { Marshal.WriteInt32(optionLength, MaxBinaryOptionSize); int rc = RetryGetSocketOptionIfInterrupted(option, optionValue.Ptr, optionLength.Ptr); value = rc == 0 ? Marshal.PtrToStringAnsi(optionValue) : string.Empty; return(rc); } }
public int GetSocketOption(int option, out byte[] value) { using (var optionLength = new DisposableIntPtr(IntPtr.Size)) using (var optionValue = new DisposableIntPtr(MaxBinaryOptionSize)) { Marshal.WriteInt32(optionLength, MaxBinaryOptionSize); int rc = RetryGetSocketOptionIfInterrupted(option, optionValue.Ptr, optionLength.Ptr); value = new byte[Marshal.ReadInt32(optionLength)]; Marshal.Copy(optionValue, value, 0, value.Length); return(rc); } }
public int SetSocketOption(int option, string value) { if (value == null) { return(RetrySetSocketOptionIfInterrupted(option, IntPtr.Zero, 0)); } var encoded = System.Text.Encoding.ASCII.GetBytes(value + "\x0"); using (var optionValue = new DisposableIntPtr(encoded.Length)) { Marshal.Copy(encoded, 0, optionValue, encoded.Length); return(RetrySetSocketOptionIfInterrupted(option, optionValue.Ptr, value.Length)); } }
public ZmqMsgT() { _ptr = new DisposableIntPtr(LibZmq.ZmqMsgTSize); }