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))); } }
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))); } }
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)); } } }
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)); } } }
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)); } } }
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)); } } } }