Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SetSocketOption() [5/5]

void System.Net.Sockets.Socket.SetSocketOption ( SocketOptionLevel optionLevel,
SocketOptionName optionName,
object optionValue )
inline

Definition at line 2176 of file Socket.cs.

2177 {
2179 if (optionValue == null)
2180 {
2181 throw new ArgumentNullException("optionValue");
2182 }
2183 if (System.Net.NetEventSource.Log.IsEnabled())
2184 {
2185 System.Net.NetEventSource.Info(this, $"optionLevel:{optionLevel} optionName:{optionName} optionValue:{optionValue}", "SetSocketOption");
2186 }
2187 if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.Linger)
2188 {
2189 if (!(optionValue is LingerOption lingerOption))
2190 {
2191 throw new ArgumentException(System.SR.Format(System.SR.net_sockets_invalid_optionValue, "LingerOption"), "optionValue");
2192 }
2193 if (lingerOption.LingerTime < 0 || lingerOption.LingerTime > 65535)
2194 {
2195 throw new ArgumentException(System.SR.Format(System.SR.ArgumentOutOfRange_Bounds_Lower_Upper_Named, 0, 65535, "optionValue.LingerTime"), "optionValue");
2196 }
2198 }
2199 else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership))
2200 {
2201 if (!(optionValue is MulticastOption mR))
2202 {
2203 throw new ArgumentException(System.SR.Format(System.SR.net_sockets_invalid_optionValue, "MulticastOption"), "optionValue");
2204 }
2206 }
2207 else
2208 {
2209 if (optionLevel != SocketOptionLevel.IPv6 || (optionName != SocketOptionName.AddMembership && optionName != SocketOptionName.DropMembership))
2210 {
2212 }
2213 if (!(optionValue is IPv6MulticastOption mR2))
2214 {
2215 throw new ArgumentException(System.SR.Format(System.SR.net_sockets_invalid_optionValue, "IPv6MulticastOption"), "optionValue");
2216 }
2218 }
2219 }
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
void SetLingerOption(LingerOption lref)
Definition Socket.cs:3534
void SetMulticastOption(SocketOptionName optionName, MulticastOption MR)
Definition Socket.cs:3508
void SetIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR)
Definition Socket.cs:3521
static string net_sockets_invalid_optionValue
Definition SR.cs:72
static string net_sockets_invalid_optionValue_all
Definition SR.cs:24
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentOutOfRange_Bounds_Lower_Upper_Named
Definition SR.cs:98
Definition SR.cs:7

References System.SR.ArgumentOutOfRange_Bounds_Lower_Upper_Named, System.SR.Format(), System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, System.SR.net_sockets_invalid_optionValue, System.SR.net_sockets_invalid_optionValue_all, System.Net.Sockets.Socket.SetIPv6MulticastOption(), System.Net.Sockets.Socket.SetLingerOption(), System.Net.Sockets.Socket.SetMulticastOption(), and System.Net.Sockets.Socket.ThrowIfDisposed().