Beispiel #1
0
 public static int SetSockOpt(int s, SocketOptionLevel level, SocketOption option, int val)
 {
     unsafe
     {
         return(Interop.nn_setsockopt(s, (int)level, (int)option, new IntPtr(&val), sizeof(int)));
     }
 }
Beispiel #2
0
 public static int SetSockOpt(int s, SocketOption option, int val)
 {
     unsafe
     {
         return(Interop.nn_setsockopt(s, Constants.NN_SOL_SOCKET, (int)option, new IntPtr(&val), sizeof(int)));
     }
 }
Beispiel #3
0
 public static int SetSockOpt(int s, SocketOptionLevel level, SocketOption option, string val)
 {
     unsafe
     {
         var bs = Encoding.UTF8.GetBytes(val);
         fixed(byte *pBs = bs)
         {
             return(Interop.nn_setsockopt(s, (int)level, (int)option, new IntPtr(pBs), bs.Length));
         }
     }
 }
Beispiel #4
0
        public static void SetInt(int socket, SocketOptionLevel level, SocketOption opts, int value)
        {
            int v = value, size = sizeof(int);

            unsafe
            {
                int result = Interop.nn_setsockopt(socket, (int)level, (int)opts, new IntPtr(&v), size);
                if (result != 0)
                {
                    throw new NanomsgException(string.Format("nn_setsockopt {0}", opts));
                }
            }
        }
Beispiel #5
0
        public static void SetTimespan(int socket, SocketOptionLevel level, SocketOption opts, TimeSpan?value)
        {
            int v = value.HasValue ? (int)value.Value.TotalMilliseconds : -1, size = sizeof(int);

            unsafe
            {
                int result = Interop.nn_setsockopt(socket, (int)level, (int)opts, new IntPtr(&v), size);
                if (result != 0)
                {
                    throw new NanomsgException(string.Format("nn_setsockopt {0}", opts));
                }
            }
        }
Beispiel #6
0
        public static void SetBytes(int socket, SocketOptionLevel level, SocketOption opts, byte[] bs)
        {
            unsafe
            {
                fixed(byte *pBs = bs)
                {
                    int result = Interop.nn_setsockopt(socket, (int)level, (int)opts, new IntPtr(pBs), bs.Length);

                    if (result != 0)
                    {
                        throw new NanomsgException(string.Format("nn_setsockopt {0}", opts));
                    }
                }
            }
        }