Okay, check check check it:
private static void Main(string[] args)
{
try
{
Socket mcSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
mcSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
new MulticastOption(IPAddress.Parse(“224.168.100.2”)));
// purposefully throw a null exception here to show that WriteException is working
Socket tempSocket = null;
if (tempSocket.SocketType == SocketType.Dgram)
{
// crash here
}
}
catch (Exception e)
{
WriteException(e);
}
}
private static void WriteException(Exception e)
{
Console.Out.WriteLine(“”);
Console.Out.WriteLine(”—————- Exception——————”);
Console.Out.WriteLine(“e.Message = {0}”, e.Message);
if (e.InnerException != null)
{
WriteException(e.InnerException);
}
}
Would you expect that innocent looking call to SetSocketOption to cause mayhem and mischief? Well, in one case, it does. And I have no idea why.
I get an “Invalid argument supplied” error (WinSock error 10022) on a certain person’s machine when making that call. What gives? What’s going on underneath that could cause this?
Things that are not causing it:
- A firewall is not running
- There is a network card in the computer
- The correct version of .NET is installed
- Windows XP Service Pack 2 is installed
- Not getting flagged by anti-virus software
I’m stumped.