title: Don't know why I'm getting Error Code 10022 (Invalid Argument) when setting socket options in my C# sniffer
body: <p>I'm writing a packet sniffer as an exercise in learning .Net 4 socket development on in C#.  My goal is to sniff IP packets coming in and out out my computer.</p>
  
  <p>My problem is that I'm getting error code 10022, invalid argument, on my call to SetSocketOption.  I don't see where I have an invalid argument.  I have some admin privs on my computer, but perhaps I don't have enough.  It's my work computer and the IT department is pretty strict.  With that said, if it was a permissions problem I would expect a different exception.</p>
  
  <p>I'm not sure what my next step should be to debug this problem.  Anyone have an idea?</p>
  
  <p>Here's the code follows:</p>
  
  <pre><code>public Sniffer()
  {
      try
      {
          socket = new Socket(
              AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
  
          IPAddress[] ipAddresses = Dns.GetHostEntry(
              Dns.GetHostName()).AddressList;
  
          socket.Bind(new IPEndPoint(ipAddresses[0], 0));
  
          socket.SetSocketOption(
              SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
  
          byte[] inputData = new byte[4] { 1, 0, 0, 0 };
          byte[] outValue = new byte[4];
  
          socket.IOControl(IOControlCode.ReceiveAll, inputData, outValue);
      }
      catch (SocketException ex)
      {
          string ErrorMessage = ex.Message;
      }
  }
  </code></pre>