Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        public int SetSocketOption(int option, byte[] value)
        {
            using (var optionValue = new DisposableIntPtr(value.Length))
            {
                Marshal.Copy(value, 0, optionValue, value.Length);

                return(RetryIfInterrupted(() => LibZmq.zmq_setsockopt(SocketHandle, option, optionValue, value.Length)));
            }
        }
Esempio n. 4
0
        public int SetSocketOption(int option, ulong value)
        {
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(ulong))))
            {
                Marshal.WriteInt64(optionValue, unchecked (Convert.ToInt64(value)));

                return(RetryIfInterrupted(() => LibZmq.zmq_setsockopt(SocketHandle, option, optionValue, sizeof(ulong))));
            }
        }
Esempio n. 5
0
        public int SetSocketOption(int option, int value)
        {
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(int))))
            {
                Marshal.WriteInt32(optionValue, value);

                return(RetryIfInterrupted(() => LibZmq.zmq_setsockopt(SocketHandle, option, optionValue, sizeof(int))));
            }
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        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.PtrToStringUni(optionValue) : string.Empty;
                return rc;
            }
        }
Esempio n. 8
0
        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 = RetryIfInterrupted(() => LibZmq.zmq_getsockopt(SocketHandle, option, optionValue, optionLength));
                    value = unchecked (Convert.ToUInt64(Marshal.ReadInt64(optionValue)));

                    return(rc);
                }
        }
Esempio n. 9
0
        public int GetSocketOption(int option, out int value)
        {
            using (var optionLength = new DisposableIntPtr(IntPtr.Size))
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(int))))
            {
                Marshal.WriteInt32(optionLength, sizeof(int));

                int rc = RetryGetSocketOptionIfInterrupted(option, optionValue.Ptr, optionLength.Ptr);
                value = Marshal.ReadInt32(optionValue);

                return rc;
            }
        }
Esempio n. 10
0
        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;
            }
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
0
        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;
            }
        }
Esempio n. 13
0
        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 = RetryIfInterrupted(() => LibZmq.zmq_getsockopt(SocketHandle, option, optionValue, optionLength));

                    value = new byte[Marshal.ReadInt32(optionLength)];
                    Marshal.Copy(optionValue, value, 0, value.Length);

                    return(rc);
                }
        }
Esempio n. 14
0
 public ZmqMsgT()
 {
     _ptr = new DisposableIntPtr(LibZmq.ZmqMsgTSize);
 }
Esempio n. 15
0
        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);
            }
        }
Esempio n. 16
0
        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));
            }
        }
Esempio n. 17
0
        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 = RetryIfInterrupted(() => LibZmq.zmq_getsockopt(SocketHandle, option, optionValue, optionLength));

                value = new byte[Marshal.ReadInt32(optionLength)];
                Marshal.Copy(optionValue, value, 0, value.Length);

                return rc;
            }
        }
Esempio n. 18
0
        public int GetSocketOption(int option, out long value)
        {
            using (var optionLength = new DisposableIntPtr(IntPtr.Size))
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(long))))
            {
                Marshal.WriteInt32(optionLength, sizeof(long));

                int rc = Retry.IfInterrupted(LibZmq.zmq_getsockopt.Invoke, SocketHandle, option, optionValue.Ptr, optionLength.Ptr);
                value = Marshal.ReadInt64(optionValue);

                return rc;
            }
        }
Esempio n. 19
0
        public int GetSocketOption(int option, out int value)
        {
            using (var optionLength = new DisposableIntPtr(IntPtr.Size))
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(int))))
            {
                Marshal.WriteInt32(optionLength, sizeof(int));

                int rc = RetryGetSocketOptionIfInterrupted(option, optionValue.Ptr, optionLength.Ptr);
                value = Marshal.ReadInt32(optionValue);

                return rc;
            }
        }
Esempio n. 20
0
        public int SetSocketOption(int option, byte[] value)
        {
            using (var optionValue = new DisposableIntPtr(value.Length))
            {
                Marshal.Copy(value, 0, optionValue, value.Length);

                return RetryIfInterrupted(() => LibZmq.zmq_setsockopt(SocketHandle, option, optionValue, value.Length));
            }
        }
Esempio n. 21
0
        public int SetSocketOption(int option, ulong value)
        {
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(ulong))))
            {
                Marshal.WriteInt64(optionValue, unchecked(Convert.ToInt64(value)));

                return RetryIfInterrupted(() => LibZmq.zmq_setsockopt(SocketHandle, option, optionValue, sizeof(ulong)));
            }
        }
Esempio n. 22
0
        public int SetSocketOption(int option, int value)
        {
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(int))))
            {
                Marshal.WriteInt32(optionValue, value);

                return RetryIfInterrupted(() => LibZmq.zmq_setsockopt(SocketHandle, option, optionValue, sizeof(int)));
            }
        }
Esempio n. 23
0
        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 = RetryIfInterrupted(() => LibZmq.zmq_getsockopt(SocketHandle, option, optionValue, optionLength));

                value = rc == 0 ? Marshal.PtrToStringAnsi(optionValue) : string.Empty;

                return rc;
            }
        }
Esempio n. 24
0
        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;
            }
        }
Esempio n. 25
0
        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;
            }
        }
Esempio n. 26
0
 public ZmqMsgT()
 {
     _ptr = new DisposableIntPtr(LibZmq.ZmqMsgTSize);
 }
Esempio n. 27
0
        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);
            }
        }
Esempio n. 28
0
        public int SetSocketOption(int option, long value)
        {
            using (var optionValue = new DisposableIntPtr(Marshal.SizeOf(typeof(long))))
            {
                Marshal.WriteInt64(optionValue, value);

                return Retry.IfInterrupted(LibZmq.zmq_setsockopt.Invoke, SocketHandle, option, optionValue.Ptr, sizeof(long));
            }
        }
Esempio n. 29
0
        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));
            }
        }
Esempio n. 30
0
        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;
            }
        }
Esempio n. 31
0
        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 = RetryIfInterrupted(() => LibZmq.zmq_getsockopt(SocketHandle, option, optionValue, optionLength));
                value = unchecked(Convert.ToUInt64(Marshal.ReadInt64(optionValue)));

                return rc;
            }
        }