1

On windows 7 (.Net 4.6.1) I am getting exception with this code:

    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)

This works fine with Windows 8 on my VM.

user007
  • 1,122
  • 1
  • 10
  • 30
  • Could you please include the whole stack trace and provide the exact operation being requested with `-1744830448`? The method also accepts `IOControlCode` objects, you may find your option there. – u354356007 Aug 18 '17 at 12:49
  • stack trace is already in the question: The attempted operation is not supported for the type of object referenced at System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue) it gives you the signature of the method that has been invoked: IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue) first argument is integer, not IOControlCode enumeration – user007 Aug 21 '17 at 08:57

1 Answers1

1

Using SIO_LOOPBACK_FAST_PATH = -1744830448 with IOControl method is not supported by Windows 7, so an exception will occur.

From 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.

Community
  • 1
  • 1
user007
  • 1,122
  • 1
  • 10
  • 30
  • How exactly does this answer the question? This reads more like an addendum to the question rather than an answer. –  Jul 31 '17 at 17:22
  • I've updated the answer, in short the answer is that Windows 7 does not support operation with specific settings – user007 Aug 21 '17 at 09:00