[Mono-list] Creating an ICMP socket fails

Jörg Rosenkranz joergr@voelcker.com
Thu, 11 Sep 2003 10:32:18 +0200


Hello, 

We try to create an ICMP socket to ping another host. Mono on Linux throws an 
exception when the constructor of the Socket class is called.

Sample code:

using System;
using System.Net;
using System.Net.Sockets;

namespace IcmpTest
{
	public class IcmpTest
	{
		public static void Main()
		{
			Socket IcmpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);
		}
	}
}

Mono throws following exception:

Unhandled Exception: System.Net.Sockets.SocketException: Some sort of w32 error occurred: 0
in (unmanaged) /home/viadmin/mono-cvs/install/lib/libmono.so.0(mono_raise_exception+0x22) [0x400aee26]
in (unmanaged) /home/viadmin/mono-cvs/install/lib/libmono.so.0 [0x400d01c6]
in [0x00035] (at /home/viadmin/mono-cvs/mcs/class/System/System.Net.Sockets/Socket.cs:417) 00 System.Net.Sockets.Socket:.ctor (System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType)
in <0x00037> 00 IcmpTest.IcmpTest:Main ()

It runs fine using MS.NET. 
Should I file a bug for this or are we doing something wrong?

Jörg