简体   繁体   English

IOControl上的System.Net.Sockets异常

[英]System.Net.Sockets exception on IOControl

On windows 7 (.Net 4.6.1) I am getting exception with this code: 在Windows 7(.Net 4.6.1)上,此代码出现异常:

    var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    socket.IOControl(-1744830448, new byte[4] { 1, 0, 0, 0 }, null);

The attempted operation is not supported for the type of object referenced at System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue) System.Net.Sockets.Socket.IOControl(Int32 ioControlCode,Byte [] optionInValue,Byte [] optionOutValue)引用的对象类型不支持尝试的操作

This works fine with Windows 8 on my VM. 在我的VM上与Windows 8配合使用时效果很好。

Using SIO_LOOPBACK_FAST_PATH = -1744830448 with IOControl method is not supported by Windows 7, so an exception will occur. Windows 7不支持将IOControl方法与SIO_LOOPBACK_FAST_PATH = -1744830448一起使用,因此会发生异常。

From the MSDN documentation for SIO_LOOPBACK_FAST_PATH : SIO_LOOPBACK_FAST_PATH的MSDN文档中

The attempted operation is not supported for the type of object referenced. 引用的对象类型不支持尝试的操作。 This error is returned if the specified IOCTL command is not supported. 如果不支持指定的IOCTL命令,则返回此错误。 This error is returned if the SIO_LOOPBACK_FAST_PATH IOCTL is used on Windows 7, Windows Server 2008 R2, and earlier versions. 如果在Windows 7,Windows Server 2008 R2和更早版本上使用SIO_LOOPBACK_FAST_PATH IOCTL,则会返回此错误。

This error is also returned if the SIO_LOOPBACK_FAST_PATH IOCTL is not supported by the transport provider. 如果传输提供程序不支持SIO_LOOPBACK_FAST_PATH IOCTL,也会返回此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM