public void GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue)
{
if (CleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
int optionLength = optionValue != null ? optionValue.Length : 0;
// This can throw ObjectDisposedException.
SocketError errorCode = SocketPal.GetSockOpt(
_handle,
optionLevel,
optionName,
optionValue,
ref optionLength);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"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 (NetEventSource.IsEnabled) NetEventSource.Error(this, socketException);
throw socketException;
}
}