title: C# SocketException with Multicast on XP
body: <p>The following C# code works correctly on Vista, but fails on XP with:</p>
  
  <p>SocketException: An invalid argument was supplied.</p>
  
  <p>The ErrorCode is 10022.</p>
  
  <p>The firewall on XP has been disabled.</p>
  
  <pre><code>using System;
  using System.Net;
  using System.Net.Sockets;
  
  public class SocketTest
  {
      [STAThread]
      public static void Main()
      {
          MySocket s = new MySocket();
  
          Console.WriteLine("done");
          Console.ReadLine();
      }
  
      public class MySocket : Socket
      {
          public const ushort SocketTtl = 4;
          public const string Address = "239.255.255.250";
  
          public IPAddress IPAddress = IPAddress.Parse(Address);
  
          public MySocket()
              : base(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
          {
              SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
              SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, SocketTtl);
  
              // This line throws SocketException: An invalid argument was supplied
              // SocketException.ErrorCode: 10022
              SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress));
          }
      }
  }
  </code></pre>
  
  <p>Any ideas?</p>