protected static int SetSocketOption(Socket socket, SocketOptionLevel level, SocketOptionName name, int value) { if (((int)socket.GetSocketOption(level, name)) == value) return value; socket.SetSocketOption(level, name, value); return (int)socket.GetSocketOption(level, name); }
protected void SetSocketOption(SocketOptionLevel level, SocketOptionName name, int option) { try { m_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, option); } catch { } }
protected static bool SetSocketOption(Socket socket, SocketOptionLevel level, SocketOptionName name, bool value) { if (((int)socket.GetSocketOption(level, name)) == (value ? 1 : 0)) return value; socket.SetSocketOption(level, name, value); if (((int)socket.GetSocketOption(level, name)) != 1) { return false; } return true; }
protected void SetSocketOption(SocketOptionLevel level, SocketOptionName name, int val) { try { sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, val); } catch { } }
internal static unsafe Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen) { bool release = false; try { socket.DangerousAddRef(ref release); return DangerousSetSockOpt((int)socket.DangerousGetHandle(), optionLevel, optionName, optionValue, optionLen); } finally { if (release) { socket.DangerousRelease(); } } }
public MulticastPolicyServerCore(AddressFamily addressFamily, MulticastPolicyConfiguration configuration) { Debug.Assert(configuration != null, "Configuration should not be null"); this.addressFamily = addressFamily; this.configuration = configuration; if (addressFamily == AddressFamily.InterNetwork) { this.localEndPoint = new IPEndPoint(IPAddress.Any, MulticastPolicyPort); this.socketOptionLevel = SocketOptionLevel.IP; } else { this.localEndPoint = new IPEndPoint(IPAddress.IPv6Any, MulticastPolicyPort); this.socketOptionLevel = SocketOptionLevel.IPv6; } SetMulticastSocketFactory(new RealMulticastSocketFactory()); }
public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue) { if (optionName == SocketOptionName.ReuseAddress) { if (this.InternalServerSocket != null) { try { //Console.WriteLine("setReuseAddress... " + new { optionValue }); this.InternalServerSocket.setReuseAddress(optionValue); } catch { throw; } } } }
public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, byte [] optionValue) { if (disposed && closed) throw new ObjectDisposedException (GetType ().ToString ()); // I'd throw an ArgumentNullException, but this is what MS does. if (optionValue == null) throw new SocketException ((int) SocketError.Fault, "Error trying to dereference an invalid pointer"); int error; SetSocketOption_internal (socket, optionLevel, optionName, null, optionValue, 0, out error); if (error != 0) { if (error == (int) SocketError.InvalidArgument) throw new ArgumentException (); throw new SocketException (error); } }
public abstract void GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue);
internal void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) { internalSocket.SetSocketOption(optionLevel, optionName, optionValue); }
public static unsafe PosixResult SetSockOpt(Socket socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte *optionValue, int optionLen) => SetSockOpt(socket.DangerousGetHandle().ToInt32(), optionLevel, optionName, optionValue, optionLen);
public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue) { ThrowIfDisposedAndClosed (); int error; SetSocketOption_internal (safe_handle, optionLevel, optionName, null, null, optionValue, out error); if (error != 0) { throw new SocketException (error); } }
internal unsafe void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue, bool silent) { GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() optionLevel:" + optionLevel + " optionName:" + optionName + " optionValue:" + optionValue + " silent:" + silent); if (silent && (CleanedUp || _handle.IsInvalid)) { GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() skipping the call"); return; } SocketError errorCode = SocketError.Success; try { errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() Interop.Winsock.setsockopt returns errorCode:" + errorCode); } catch { if (silent && _handle.IsInvalid) { return; } throw; } // Keep the internal state in sync if the user manually resets this. if (optionName == SocketOptionName.PacketInformation && optionValue == 0 && errorCode == SocketError.Success) { _receivingPacketInformation = false; } if (silent) { return; } // Throw an appropriate SocketException if the native call fails. if (errorCode != SocketError.Success) { // Update the internal state of this socket according to the error before throwing. SocketException socketException = new SocketException((int)errorCode); UpdateStatusAfterSocketError(socketException); if (s_loggingEnabled) { Logging.Exception(Logging.Sockets, this, "SetSocketOption", socketException); } throw socketException; } }
// Sets the specified option to the specified value. public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) { if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } // Validate input parameters. if (optionValue == null) { throw new ArgumentNullException("optionValue"); } CheckSetOptionPermissions(optionLevel, optionName); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption(): optionLevel:" + optionLevel.ToString() + " optionName:" + optionName.ToString() + " optionValue:" + optionValue.ToString()); if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) { LingerOption lingerOption = optionValue as LingerOption; if (lingerOption == null) { throw new ArgumentException(SR.Format(SR.net_sockets_invalid_optionValue, "LingerOption"), "optionValue"); } if (lingerOption.LingerTime < 0 || lingerOption.LingerTime > (int)UInt16.MaxValue) { throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, 0, (int)UInt16.MaxValue), "optionValue.LingerTime"); } SetLingerOption(lingerOption); } else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { MulticastOption multicastOption = optionValue as MulticastOption; if (multicastOption == null) { throw new ArgumentException(SR.Format(SR.net_sockets_invalid_optionValue, "MulticastOption"), "optionValue"); } SetMulticastOption(optionName, multicastOption); } else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { // IPv6 Changes: Handle IPv6 Multicast Add / Drop IPv6MulticastOption multicastOption = optionValue as IPv6MulticastOption; if (multicastOption == null) { throw new ArgumentException(SR.Format(SR.net_sockets_invalid_optionValue, "IPv6MulticastOption"), "optionValue"); } SetIPv6MulticastOption(optionName, multicastOption); } else { throw new ArgumentException(SR.net_sockets_invalid_optionValue_all, "optionValue"); } }
private int numericOption(SocketOptionLevel optionLevel, SocketOptionName optionName) { return((int)Client.GetSocketOption(optionLevel, optionName)); }
public static extern SocketError getsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, out IPv6MulticastRequest optionValue, [In, Out] ref int optionLength);
public static extern SocketError getsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, out Linger optionValue, [In, Out] ref int optionLength);
public static extern SocketError setsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref IPMulticastRequest mreq, [In] int optionLength);
public static extern SocketError setsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref Linger linger, [In] int optionLength);
public static extern SocketError setsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] byte[] optionValue, [In] int optionLength);
internal static extern SocketError setsockopt( [In] SafeCloseSocket socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref IntPtr pointer, [In] int optionLength);
private int numericOption(SocketOptionLevel optionLevel, SocketOptionName optionName) { return (int)Client.GetSocketOption(optionLevel, optionName); }
public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) { if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } CheckSetOptionPermissions(optionLevel, optionName); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption(): optionLevel:" + optionLevel.ToString() + " optionName:" + optionName.ToString() + " optionValue:" + optionValue.ToString()); // This can throw ObjectDisposedException. SocketError errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption() Interop.Winsock.setsockopt returns errorCode:" + errorCode); // Throw an appropriate SocketException if the native call fails. if (errorCode != SocketError.Success) { // Update the internal state of this socket according to the error before throwing. SocketException socketException = new SocketException((int)errorCode); UpdateStatusAfterSocketError(socketException); if (s_loggingEnabled) { Logging.Exception(Logging.Sockets, this, "SetSocketOption", socketException); } throw socketException; } }
private static extern int setsockopt(IntPtr socket, SocketOptionLevel level, SocketOptionName optName, ref IntPtr optVal, int optLen);
public byte[] GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength) { if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } byte[] optionValue = new byte[optionLength]; int realOptionLength = optionLength; // This can throw ObjectDisposedException. SocketError errorCode = SocketPal.GetSockOpt( _handle, optionLevel, optionName, optionValue, ref realOptionLength); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::GetSocketOption() Interop.Winsock.getsockopt returns errorCode:" + errorCode); // Throw an appropriate SocketException if the native call fails. if (errorCode != SocketError.Success) { // Update the internal state of this socket according to the error before throwing. SocketException socketException = new SocketException((int)errorCode); UpdateStatusAfterSocketError(socketException); if (s_loggingEnabled) { Logging.Exception(Logging.Sockets, this, "GetSocketOption", socketException); } throw socketException; } if (optionLength != realOptionLength) { byte[] newOptionValue = new byte[realOptionLength]; Buffer.BlockCopy(optionValue, 0, newOptionValue, 0, realOptionLength); optionValue = newOptionValue; } return optionValue; }
/// <summary> /// Intitalizes one socket based on the given parameters. /// </summary> /// <param name="sock">The socket class to be initalized</param> /// <param name="addrFamily">The address family for the socket to be initalized to (InterNetwork/InterNetworkV6)</param> /// <param name="isUnicast">Wether this socket is to be used for Multicast or Unicast</param> /// <param name="traffType">Wether this socket is to be used for RTP traffic or RTCP</param> private static void InitSocket(out Socket sock, TrafficType traffTypes) { int bindPort = 0; SocketOptionLevel sOL = 0; AddressFamily addrFamily = AddressFamily.InterNetwork; IPAddress bindInterface = null; #region initalizing bindPort, sOL, addrFamily and BindInterface based on function prarameters switch (traffTypes) { case TrafficType.UCv4RTP: bindInterface = ReflectorMgr.UnicastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.UCv6RTP: bindInterface = ReflectorMgr.IPv6UnicastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.MCv4RTP: bindInterface = ReflectorMgr.MulticastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.MCv6RTP: bindInterface = ReflectorMgr.IPv6MulticastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.UCv4RTCP: bindInterface = ReflectorMgr.UnicastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort + 1; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.UCv6RTCP: bindInterface = ReflectorMgr.IPv6UnicastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort + 1; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.MCv4RTCP: bindInterface = ReflectorMgr.MulticastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort + 1; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.MCv6RTCP: bindInterface = ReflectorMgr.IPv6MulticastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort + 1; addrFamily = AddressFamily.InterNetworkV6; break; default: Debug.Assert(false); throw new ArgumentException(Strings.InvalidTrafficTypeCombination); } #endregion sock = new Socket(addrFamily, SocketType.Dgram, ProtocolType.Udp); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 1500 * 160); // Multicast receive only if ((traffTypes & TrafficType.Multicast) == TrafficType.Multicast) { sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, -1); } // Unicast socket sends multicast data, so set some multicast sending properties on it if ((traffTypes & TrafficType.Unicast) == TrafficType.Unicast) { sock.SetSocketOption(sOL, SocketOptionName.MulticastTimeToLive, 128); // Only set this value if it is other than the default if (ReflectorMgr.MulticastInterfaceRouteIndex > 0) { sock.SetSocketOption(sOL, SocketOptionName.MulticastInterface, (int)IPAddress.HostToNetworkOrder(ReflectorMgr.MulticastInterfaceRouteIndex)); } } sock.Bind(new IPEndPoint(bindInterface, bindPort)); if (((traffTypes & TrafficType.Multicast) == TrafficType.Multicast) && (!ReflectorMgr.MCLoopbackOff)) { sock.SetSocketOption(sOL, SocketOptionName.MulticastLoopback, 1); } }
internal static extern SocketError setsockopt( [In] SafeCloseSocket socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] byte[] optionValue, [In] int optionLength);
public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int value) { TrySetSocketOption(optionLevel, optionName, value) .ThrowOnError(); }
extern static void SetSocketOption_internal (IntPtr socket, SocketOptionLevel level, SocketOptionName name, object obj_val, byte [] byte_val, int int_val, out int error);
public unsafe PosixResult TrySetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int value) { return(SocketInterop.SetSockOpt(this, optionLevel, optionName, (byte *)&value, 4)); }
public static extern unsafe PosixResult SetSockOpt(int socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte *optionValue, int optionLen);
public static extern unsafe PosixResult GetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte *optionValue, int *optionLen);
public abstract byte[] GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength);
private static extern unsafe Error DangerousGetSockOpt(int socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte *optionValue, int *optionLen);
public static void SetIPProtectionLevel(Socket socket, SocketOptionLevel optionLevel, int protectionLevel) { socket.SetSocketOption(optionLevel, SocketOptionName.IPProtectionLevel, protectionLevel); }
internal static extern unsafe Error GetSockOpt(int socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte *optionValue, int *optionLen);
public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue) { if (disposed && closed) throw new ObjectDisposedException (GetType ().ToString ()); int error; int int_val = (optionValue) ? 1 : 0; SetSocketOption_internal (socket, optionLevel, optionName, null, null, int_val, out error); if (error != 0) { if (error == (int) SocketError.InvalidArgument) throw new ArgumentException (); throw new SocketException (error); } }
public void SetIPProtectionLevel_Windows(IPProtectionLevel level, AddressFamily family, SocketOptionLevel optionLevel) { using (var socket = new Socket(family, SocketType.Stream, ProtocolType.Tcp)) { socket.SetIPProtectionLevel(level); int result = (int)socket.GetSocketOption(optionLevel, SocketOptionName.IPProtectionLevel); Assert.Equal(result, (int)level); } }
// Sets the specified option to the specified value. public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue) { if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } CheckSetOptionPermissions(optionLevel, optionName); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::SetSocketOption(): optionLevel:" + optionLevel.ToString() + " optionName:" + optionName.ToString() + " optionValue:" + optionValue.ToString()); SetSocketOption(optionLevel, optionName, optionValue, false); }
public void GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, byte [] optionValue) { ThrowIfDisposedAndClosed (); if (optionValue == null) throw new SocketException ((int) SocketError.Fault, "Error trying to dereference an invalid pointer"); int error; GetSocketOption_arr_internal (safe_handle, optionLevel, optionName, ref optionValue, out error); if (error != 0) throw new SocketException (error); }
// Sets the specified option to the specified value. public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue) { SetSocketOption(optionLevel, optionName, (optionValue ? 1 : 0)); }
public object GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName) { ThrowIfDisposedAndClosed (); int error; object obj_val; GetSocketOption_obj_internal (safe_handle, optionLevel, optionName, out obj_val, out error); if (error != 0) throw new SocketException (error); if (optionName == SocketOptionName.Linger) return (LingerOption) obj_val; else if (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership) return (MulticastOption) obj_val; else if (obj_val is int) return (int) obj_val; else return obj_val; }
// Gets the value of a socket option. public object GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName) { if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) { return GetLingerOpt(); } else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { return GetMulticastOpt(optionName); } else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { // Handle IPv6 case return GetIPv6MulticastOpt(optionName); } int optionValue = 0; // This can throw ObjectDisposedException. SocketError errorCode = SocketPal.GetSockOpt( _handle, optionLevel, optionName, out optionValue); GlobalLog.Print("Socket#" + Logging.HashString(this) + "::GetSocketOption() Interop.Winsock.getsockopt returns errorCode:" + errorCode); // Throw an appropriate SocketException if the native call fails. if (errorCode != SocketError.Success) { // Update the internal state of this socket according to the error before throwing. SocketException socketException = new SocketException((int)errorCode); UpdateStatusAfterSocketError(socketException); if (s_loggingEnabled) { Logging.Exception(Logging.Sockets, this, "GetSocketOption", socketException); } throw socketException; } return optionValue; }
extern static void GetSocketOption_obj_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, out object obj_val, out int error);
private void CheckSetOptionPermissions(SocketOptionLevel optionLevel, SocketOptionName optionName) { // Freely allow only the options listed below. if (!(optionLevel == SocketOptionLevel.Tcp && (optionName == SocketOptionName.NoDelay || optionName == SocketOptionName.BsdUrgent || optionName == SocketOptionName.Expedited)) && !(optionLevel == SocketOptionLevel.Udp && (optionName == SocketOptionName.NoChecksum || optionName == SocketOptionName.ChecksumCoverage)) && !(optionLevel == SocketOptionLevel.Socket && (optionName == SocketOptionName.KeepAlive || optionName == SocketOptionName.Linger || optionName == SocketOptionName.DontLinger || optionName == SocketOptionName.SendBuffer || optionName == SocketOptionName.ReceiveBuffer || optionName == SocketOptionName.SendTimeout || optionName == SocketOptionName.ExclusiveAddressUse || optionName == SocketOptionName.ReceiveTimeout)) && !(optionLevel == SocketOptionLevel.IPv6 && optionName == (SocketOptionName)23)) // IPv6 protection level. { } }
public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) { ThrowIfDisposedAndClosed (); // NOTE: if a null is passed, the byte[] overload is used instead... if (optionValue == null) throw new ArgumentNullException("optionValue"); int error; if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) { LingerOption linger = optionValue as LingerOption; if (linger == null) throw new ArgumentException ("A 'LingerOption' value must be specified.", "optionValue"); SetSocketOption_internal (safe_handle, optionLevel, optionName, linger, null, 0, out error); } else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { MulticastOption multicast = optionValue as MulticastOption; if (multicast == null) throw new ArgumentException ("A 'MulticastOption' value must be specified.", "optionValue"); SetSocketOption_internal (safe_handle, optionLevel, optionName, multicast, null, 0, out error); } else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) { IPv6MulticastOption multicast = optionValue as IPv6MulticastOption; if (multicast == null) throw new ArgumentException ("A 'IPv6MulticastOption' value must be specified.", "optionValue"); SetSocketOption_internal (safe_handle, optionLevel, optionName, multicast, null, 0, out error); } else { throw new ArgumentException ("Invalid value specified.", "optionValue"); } if (error != 0) { if (error == (int) SocketError.InvalidArgument) throw new ArgumentException (); throw new SocketException (error); } }
internal static unsafe extern SocketError setsockopt( [In] SafeSocketHandle socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] byte *optionValue, [In] int optionLength);
/// <summary> /// Socket选项设置 /// </summary> /// <param name="optionLevel"></param> /// <param name="optionName"></param> /// <param name="optionValue"></param> public abstract void SetSocketOptions(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue);
public byte [] GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, int length) { ThrowIfDisposedAndClosed (); int error; byte[] byte_val = new byte [length]; GetSocketOption_arr_internal (safe_handle, optionLevel, optionName, ref byte_val, out error); if (error != 0) throw new SocketException (error); return byte_val; }
internal static extern SocketError setsockopt( [In] SafeSocketHandle socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref Linger linger, [In] int optionLength);
extern static void GetSocketOption_arr_internal(IntPtr socket, SocketOptionLevel level, SocketOptionName name, ref byte[] byte_val, out int error);
internal static extern SocketError setsockopt( [In] SafeSocketHandle socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref IPv6MulticastRequest mreq, [In] int optionLength);
public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, byte [] optionValue) { ThrowIfDisposedAndClosed (); // I'd throw an ArgumentNullException, but this is what MS does. if (optionValue == null) throw new SocketException ((int) SocketError.Fault, "Error trying to dereference an invalid pointer"); int error; SetSocketOption_internal (safe_handle, optionLevel, optionName, null, optionValue, 0, out error); if (error != 0) { if (error == (int) SocketError.InvalidArgument) throw new ArgumentException (); throw new SocketException (error); } }
/// <summary>See <see cref="T:System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel, SocketOptionName)" />.</summary> public object GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName) { return(client.Client.GetSocketOption(optionLevel, optionName)); }
public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue) { ThrowIfDisposedAndClosed (); int error; int int_val = optionValue ? 1 : 0; SetSocketOption_internal (safe_handle, optionLevel, optionName, null, null, int_val, out error); if (error != 0) { if (error == (int) SocketError.InvalidArgument) throw new ArgumentException (); throw new SocketException (error); } }
/// <summary>See <see cref="T:System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel, SocketOptionName, byte[])" />.</summary> public void GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) { client.Client.GetSocketOption(optionLevel, optionName, optionValue); }
static void SetSocketOption_internal (SafeSocketHandle safeHandle, SocketOptionLevel level, SocketOptionName name, object obj_val, byte [] byte_val, int int_val, out int error) { bool release = false; try { safeHandle.DangerousAddRef (ref release); SetSocketOption_internal (safeHandle.DangerousGetHandle (), level, name, obj_val, byte_val, int_val, out error); } finally { if (release) safeHandle.DangerousRelease (); } }
/// <summary>See <see cref="T:System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel, SocketOptionName, int)" />.</summary> public byte[] GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength) { return(client.Client.GetSocketOption(optionLevel, optionName, optionLength)); }
internal void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) { internalSocket.SetSocketOption(optionLevel, optionName, optionValue); }
/// <summary>See <see cref="T:System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel, SocketOptionName, object)" />.</summary> public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) { client.Client.SetSocketOption(optionLevel, optionName, optionValue); }