public static unsafe SocketError SetSockOpt(SafeCloseSocket handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue)
{
Interop.Error err;
if (optionValue == null || optionValue.Length == 0)
{
err = Interop.Sys.SetSockOpt(handle, optionLevel, optionName, null, 0);
}
else
{
fixed (byte* pinnedValue = optionValue)
{
err = Interop.Sys.SetSockOpt(handle, optionLevel, optionName, pinnedValue, optionValue.Length);
}
}
return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
}