public static int GetSockOpt(int s, SocketOption option, out int val) { int optvallen = sizeof(int); int optval = 0; int rc = Interop.nn_getsockopt(s, Constants.NN_SOL_SOCKET, (int)option, ref optval, ref optvallen); val = optval; return rc; }
public static TimeSpan? GetTimespan(int socket, SocketOptionLevel level, SocketOption opts) { int value = 0, size = sizeof(int); int result = Interop.nn_getsockopt(socket, (int)level, (int)opts, ref value, ref size); if (result != 0) throw new NanomsgException(string.Format("nn_getsockopt {0}", opts)); return value < 0 ? (TimeSpan?)null : TimeSpan.FromMilliseconds(value); }
public static void SetString(int socket, SocketOptionLevel level, SocketOption opts, string value) { var bs = Encoding.UTF8.GetBytes(value); SetBytes(socket, level, opts, bs); }
/// <summary> /// Gets socket option value. /// </summary> /// <param name="option">Option to get.</param> /// <returns></returns> public dynamic GetOption( SocketOption option ) { switch( option ) { case SocketOption.SocketIdentity: return GetOptionString( (int)option ); case SocketOption.HighWaterMark: case SocketOption.ThreadAffinity: case SocketOption.SendBuffer: case SocketOption.ReceiveBuffer: return GetOptionUInt64( (int)option ); case SocketOption.SwapSize: case SocketOption.MoreToFollow: return GetOptionInt64( (int)option ); case SocketOption.SocketType: case SocketOption.Linger: case SocketOption.ReconnectInterval: case SocketOption.ReconnectIntervalMax: case SocketOption.ConnectionBacklog: return GetOptionInt32( (int)option ); default: throw new NotImplementedException( "Unknown option: " + option ); } }
/// <summary> /// Sets socket options. /// </summary> /// <param name="option">Option to set.</param> /// <param name="value">Value to set the option to.</param> public void SetOption( SocketOption option, ulong value ) { Contract.Requires( !Disposed ); Contract.Requires( option == SocketOption.HighWaterMark || option == SocketOption.ThreadAffinity || option == SocketOption.SendBuffer || option == SocketOption.ReceiveBuffer ); if( C.zmq_setsockopt( m_sock, (int)option, ref value, new C.size_t( Marshal.SizeOf( value ) ) ) != 0 ) { throw ZeroMQException.CurrentError(); } }
/// <summary> /// Sets socket options. /// </summary> /// <param name="option">Option to set.</param> /// <param name="value">Value to set the option to.</param> public void SetOption( SocketOption option, byte[] value ) { Contract.Requires( !Disposed ); Contract.Requires( option == SocketOption.SocketIdentity || option == SocketOption.Subscribe || option == SocketOption.Unsubscribe ); Contract.Requires( value != null ); Contract.Requires( option != SocketOption.SocketIdentity || ( value.Length <= 255 && value.Length > 0 ) ); //Automatic marshalling of the byte array doesn't quite seem to work. IntPtr valuePtr = Marshal.AllocHGlobal( value.Length ); try { Marshal.Copy( value, 0, valuePtr, value.Length ); if( C.zmq_setsockopt( m_sock, (int)option, valuePtr, new C.size_t( value.Length ) ) != 0 ) { throw ZeroMQException.CurrentError(); } } finally { Marshal.FreeHGlobal( valuePtr ); } }
internal byte[] GetSocketOptionBytes(SocketOption option) { this.EnsureNotDisposed(); byte[] value; this.HandleProxyResult(this.proxy.GetSocketOption((int)option, out value)); return value; }
internal int GetSocketOptionInt32(SocketOption option) { this.EnsureNotDisposed(); int value; this.HandleProxyResult(this.proxy.GetSocketOption((int)option, out value)); return value; }
public abstract T GetOption(SocketOption <T> name);
/// <exception cref="IllegalArgumentException"> {@inheritDoc} </exception> /// <exception cref="ClosedChannelException"> {@inheritDoc} </exception> /// <exception cref="IOException"> {@inheritDoc} </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public abstract <T> AsynchronousServerSocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException; public abstract AsynchronousServerSocketChannel setOption <T>(SocketOption <T> name, T value);
/// <summary> /// Convinience constructor /// </summary> public GetOptRequest(SocketOption option) { Option = option; }
public BluetoothClient(Socket socket) { _socket = socket; option = new SocketOption(socket); }
public BluetoothClient() { _socket = new BluetoothSocket(); option = new SocketOption(Socket); }
/// <exception cref="UnsupportedOperationException"> {@inheritDoc} </exception> /// <exception cref="IllegalArgumentException"> {@inheritDoc} </exception> /// <exception cref="ClosedChannelException"> {@inheritDoc} </exception> /// <exception cref="IOException"> {@inheritDoc} /// /// @since 1.7 </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public abstract <T> ServerSocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException; public abstract ServerSocketChannel setOption <T>(SocketOption <T> name, T value);
public static void SetString(int socket, SocketOptionLevel level, SocketOption opts, string value) { string v = value; int size = value.Length; int result = Interop.nn_setsockopt_string(socket, (int)level, (int)opts, v, size); if (result != 0) throw new NanomsgException(string.Format("nn_setsockopt {0}", opts)); }
/// <exception cref="UnsupportedOperationException"> {@inheritDoc} </exception> /// <exception cref="IllegalArgumentException"> {@inheritDoc} </exception> /// <exception cref="ClosedChannelException"> {@inheritDoc} </exception> /// <exception cref="IOException"> {@inheritDoc} /// /// @since 1.7 </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public abstract <T> DatagramChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException; public abstract DatagramChannel setOption <T>(SocketOption <T> name, T value);
public SocketOptionBuilder() { _socketOption = new SocketOption(); }
internal ulong GetSocketOptionUInt64(SocketOption option) { this.EnsureNotDisposed(); ulong value; this.HandleProxyResult(this.proxy.GetSocketOption((int)option, out value)); return value; }
public static int SetSockOpt(int s, SocketOption option, string val) { return Interop.nn_setsockopt_string(s, Constants.NN_SOL_SOCKET, (int)option, val, val.Length); }
/// <summary> /// Sets socket options. /// </summary> /// <param name="option">Option to set.</param> /// <param name="value">Value to set the option to.</param> /// <param name="encoding">Encoding to use for the string value.</param> public void SetOption( SocketOption option, string value, Encoding encoding ) { Contract.Requires( !Disposed ); Contract.Requires( option == SocketOption.SocketIdentity || option == SocketOption.Subscribe || option == SocketOption.Unsubscribe ); Contract.Requires( value != null ); Contract.Requires( option != SocketOption.SocketIdentity || value.Length <= 255 ); SetOption( option, encoding.GetBytes( value ) ); }
public static int SetSockOpt(int s, SocketOption option, int val) { return Interop.nn_setsockopt_int(s, Constants.NN_SOL_SOCKET, (int)option, ref val, sizeof(int)); }
/// <summary> /// Sets socket options. /// </summary> /// <param name="option">Option to set.</param> /// <param name="value">Value to set the option to.</param> public void SetOption( SocketOption option, long value ) { Contract.Requires( !Disposed ); Contract.Requires( option == SocketOption.SwapSize ); if( C.zmq_setsockopt( m_sock, (int)option, ref value, new C.size_t( Marshal.SizeOf( value ) ) ) != 0 ) { throw ZeroMQException.CurrentError(); } }
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); } } }
/// <summary> /// Sets socket options. /// </summary> /// <param name="option">Option to set.</param> /// <param name="value">Value to set the option to.</param> public void SetOption( SocketOption option, int value ) { Contract.Requires( !Disposed ); Contract.Requires( option == SocketOption.Linger || option == SocketOption.ReconnectInterval || option == SocketOption.ConnectionBacklog || option == SocketOption.ReconnectIntervalMax ); if( C.zmq_setsockopt( m_sock, (int)option, ref value, new C.size_t( Marshal.SizeOf( value ) ) ) != 0 ) { throw ZeroMQException.CurrentError(); } }
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 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)); } } }
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 string GetString(int socket, SocketOptionLevel level, SocketOption opts) { string value = null; int size = 0; int result = Interop.nn_getsockopt(socket, (int)level, (int)opts, ref value, ref size); if (result != 0) throw new NanomsgException(string.Format("nn_getsockopt {0}", opts)); return value; }
internal void SetSocketOption(SocketOption option, ulong value) { this.EnsureNotDisposed(); this.HandleProxyResult(this.proxy.SetSocketOption((int)option, value)); }
public static void SetInt(int socket, SocketOptionLevel level, SocketOption opts, int value) { int v = value, size = sizeof(int); int result = Interop.nn_setsockopt_int(socket, (int)level, (int)opts, ref v, size); if (result != 0) throw new NanomsgException(string.Format("nn_setsockopt {0}", opts)); }
internal void SetSocketOption(SocketOption option, byte[] value) { this.EnsureNotDisposed(); if (value == null) { throw new ArgumentNullException("value"); } this.HandleProxyResult(this.proxy.SetSocketOption((int)option, value)); }
public static void SetTimespan(int socket, SocketOptionLevel level, SocketOption opts, TimeSpan? value) { int v = value.HasValue ? (int)value.Value.TotalMilliseconds : -1, size = sizeof(int); int result = Interop.nn_setsockopt_int(socket, (int)level, (int)opts, ref v, size); if (result != 0) throw new NanomsgException(string.Format("nn_setsockopt {0}", opts)); }
/// <summary> /// Constructor /// </summary> /// <param name="option"></param> /// <param name="value"></param> public SocketOptionValue(SocketOption option, ulong value) { Option = option; Value = value; }