System.Net.Sockets IOControl 异常
System.Net.Sockets exception on IOControl
在 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);
引用的对象类型不支持尝试的操作
在 System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue)
我的 VM 上的 Windows 8 可以正常工作。
使用 SIO_LOOPBACK_FAST_PATH = -1744830448 和 IOControl 方法
Windows7不支持,所以会出现异常。
来自the MSDN documentation for SIO_LOOPBACK_FAST_PATH:
The attempted operation is not supported for the type of object referenced. This error is returned if the specified IOCTL command is not supported. This error is returned if the SIO_LOOPBACK_FAST_PATH IOCTL is used on Windows 7, Windows Server 2008 R2, and earlier versions.
This error is also returned if the SIO_LOOPBACK_FAST_PATH IOCTL is not supported by the transport provider.
在 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);
引用的对象类型不支持尝试的操作 在 System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue)
我的 VM 上的 Windows 8 可以正常工作。
使用 SIO_LOOPBACK_FAST_PATH = -1744830448 和 IOControl 方法 Windows7不支持,所以会出现异常。
来自the MSDN documentation for SIO_LOOPBACK_FAST_PATH:
The attempted operation is not supported for the type of object referenced. This error is returned if the specified IOCTL command is not supported. This error is returned if the SIO_LOOPBACK_FAST_PATH IOCTL is used on Windows 7, Windows Server 2008 R2, and earlier versions.
This error is also returned if the SIO_LOOPBACK_FAST_PATH IOCTL is not supported by the transport provider.