135 references to SocketOptionName
netstandard (1)
netstandard.cs (1)
1277[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.SocketOptionName))]
System (1)
src\libraries\shims\System\ref\System.cs (1)
767[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.SocketOptionName))]
System.Net.Ping (1)
System\Net\NetworkInformation\Ping.RawSocket.cs (1)
89socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, 1);
System.Net.Requests (3)
System\Net\HttpWebRequest.cs (3)
1777socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); 1778socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, keepAlive.Time); 1779socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, keepAlive.Interval);
System.Net.Sockets (129)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetSockOpt.cs (2)
13internal static unsafe partial Error GetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int* optionLen); 16internal static unsafe partial Error GetSockOpt(IntPtr socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int* optionLen);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.SetSockOpt.cs (2)
13internal static unsafe partial Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen); 16internal static unsafe partial Error SetSockOpt(IntPtr socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen);
System\Net\Sockets\NetworkStream.cs (4)
123int timeout = (int)_streamSocket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout)!; 150int timeout = (int)_streamSocket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout)!; 699_streamSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, timeout, silent); 708_streamSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout, silent);
System\Net\Sockets\SafeSocketHandle.Unix.cs (13)
58internal void TrackOption(SocketOptionLevel level, SocketOptionName name) 66case SocketOptionName.NoDelay: _trackedOptions |= TrackedSocketOptions.NoDelay; return; 73case SocketOptionName.DontFragment: _trackedOptions |= TrackedSocketOptions.DontFragment; return; 74case SocketOptionName.IpTimeToLive: _trackedOptions |= TrackedSocketOptions.Ttl; return; 81case SocketOptionName.IPv6Only: _trackedOptions |= TrackedSocketOptions.DualMode; return; 82case SocketOptionName.IpTimeToLive: _trackedOptions |= TrackedSocketOptions.Ttl; return; 89case SocketOptionName.Broadcast: _trackedOptions |= TrackedSocketOptions.EnableBroadcast; return; 90case SocketOptionName.Linger: _trackedOptions |= TrackedSocketOptions.LingerState; return; 91case SocketOptionName.ReceiveBuffer: _trackedOptions |= TrackedSocketOptions.ReceiveBufferSize; return; 92case SocketOptionName.ReceiveTimeout: _trackedOptions |= TrackedSocketOptions.ReceiveTimeout; return; 93case SocketOptionName.SendBuffer: _trackedOptions |= TrackedSocketOptions.SendBufferSize; return; 94case SocketOptionName.SendTimeout: _trackedOptions |= TrackedSocketOptions.SendTimeout; return; 208Interop.Error err = Interop.Sys.GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Type, (byte*)&type, &optLen);
System\Net\Sockets\Socket.cs (57)
500return (int)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse)! != 0 ? true : false; 508SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, value ? 1 : 0); 516return (int)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer)!; 522SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, value); 530return (int)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer)!; 537SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, value); 546return (int)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout)!; 557SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, value); 566return (int)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout)!; 578SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, value); 589return (LingerOption?)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger); 595SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, value!); 603return (int)GetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay)! != 0 ? true : false; 607SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, value ? 1 : 0); 617return (short)(int)GetSocketOption(SocketOptionLevel.IP, SocketOptionName.IpTimeToLive)!; 621return (short)(int)GetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IpTimeToLive)!; 637SetSocketOption(SocketOptionLevel.IP, SocketOptionName.IpTimeToLive, value); 642SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IpTimeToLive, value); 659return (int)GetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment)! != 0 ? true : false; 673SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, value ? 1 : 0); 692return (int)GetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback)! != 0 ? true : false; 696return (int)GetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.MulticastLoopback)! != 0 ? true : false; 709SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback, value ? 1 : 0); 714SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.MulticastLoopback, value ? 1 : 0); 731return (int)GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast)! != 0 ? true : false; 736SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, value ? 1 : 0); 756return ((int)GetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only)! == 0); 767SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, value ? 0 : 1); 2080public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue) 2088public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) 2107public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue) 2113public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) 2120if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) 2133else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) 2142else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) 2166/// The <see cref="SetRawSocketOption"/> should be used only when <see cref="SocketOptionLevel"/> and <see cref="SocketOptionName"/> 2184public object? GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName) 2187if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger) 2191else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) 2195else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) 2221public void GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) 2244public byte[] GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength) 2286/// The <see cref="GetRawSocketOption"/> should be used only when <see cref="SocketOptionLevel"/> and <see cref="SocketOptionName"/> 3461SocketOptionName.ReceiveTimeout, 3574SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true); 3585SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.PacketInformation, true); 3592internal void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue, bool silent) 3595if (OperatingSystem.IsWasi() && optionName == SocketOptionName.PacketInformation) 3625if (optionName == SocketOptionName.PacketInformation && optionValue == 0 && 3643private void SetMulticastOption(SocketOptionName optionName, MulticastOption MR) 3657private void SetIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR) 3703private MulticastOption? GetMulticastOpt(SocketOptionName optionName) 3720private IPv6MulticastOption? GetIPv6MulticastOpt(SocketOptionName optionName)
System\Net\Sockets\SocketPal.Unix.cs (33)
78error = Interop.Sys.SetSockOpt(fd, SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, (byte*)&on, sizeof(int)); 1421private static SocketError GetErrorAndTrackSetting(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, Interop.Error err) 1431public static unsafe SocketError SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue) 1437if (optionName == SocketOptionName.ReceiveTimeout) 1443else if (optionName == SocketOptionName.SendTimeout) 1452if (optionName == SocketOptionName.MulticastInterface) 1476if (optionLevel == SocketOptionLevel.IPv6 && optionName == SocketOptionName.IPv6Only) 1502public static unsafe SocketError SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) 1532public static unsafe SocketError SetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, MulticastOption optionValue) 1534Debug.Assert(optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership, $"Unexpected optionName: {optionName}"); 1536Interop.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ? 1555public static unsafe SocketError SetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, IPv6MulticastOption optionValue) 1557Debug.Assert(optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership, $"Unexpected optionName={optionName}"); 1559Interop.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ? 1580return GetErrorAndTrackSetting(handle, SocketOptionLevel.Socket, SocketOptionName.Linger, err); 1589socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true); 1600public static unsafe SocketError GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, out int optionValue) 1604if (optionName == SocketOptionName.ReceiveTimeout) 1609else if (optionName == SocketOptionName.SendTimeout) 1616if (optionName == SocketOptionName.Error) 1643public static unsafe SocketError GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue, ref int optionLength) 1653else if (optionName == SocketOptionName.Error && optionValue.Length >= sizeof(int)) 1703public static unsafe SocketError GetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out MulticastOption? optionValue) 1705Debug.Assert(optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership, $"Unexpected optionName={optionName}"); 1707Interop.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ? 1728public static unsafe SocketError GetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out IPv6MulticastOption? optionValue) 1730Debug.Assert(optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership, $"Unexpected optionName={optionName}"); 1732Interop.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ? 2191SocketError errorCode = GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Error, out int optionValue);
System\Net\Sockets\TCPClient.cs (8)
308get { return (int)Client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer)!; } 309set { Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, value); } 315get { return (int)Client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer)!; } 316set { Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, value); } 325return (int)Client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout)!; 330Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, value); 340return (int)Client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout)!; 345Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, value);
System\Net\Sockets\TCPListener.cs (1)
132Start((int)SocketOptionName.MaxConnections);
System\Net\Sockets\UDPClient.cs (9)
262_clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); 409SocketOptionName.AddMembership, 416SocketOptionName.AddMembership, 432SocketOptionName.AddMembership, 452SocketOptionName.AddMembership, 473SocketOptionName.MulticastTimeToLive, 493SocketOptionName.DropMembership, 500SocketOptionName.DropMembership, 520SocketOptionName.DropMembership,