[Mono-dev] Socket address and protocol families
TThompson at Nucsafe.com
Tue May 11 09:20:18 EDT 2010
> I'm wanting to access the SocketCAN (Controller Area Network)
infrastructure from Mono.
> SocketCAN is part of the kernel networking infrastructure.
> It uses the standard sockets system calls with address family being
set to AF_CAN (29) and protocol family set to PF_CAN (29).
> Is there a way of extending the AddressFamily and ProtocolFamily
values to use the above?
I ran into a similar issue when trying to use Bluetooth in Linux. The
native socket interface supports it, but Mono catches an unknown
protocol type and returns an exception before it gets down to that
level. I patched around it in socket-io.c by disabling Mono's checks and
letting it hand the values directly down to the OS. If you get something
wrong, you'll still know about it because you'll get an exception from
the failed system call. I believe the reason that this isn't the default
behavior is that there is not a 1:1 mapping of Linux socket errors to
the exceptions that are supposed to be thrown in various circumstances.
If Mono didn't pre-filter the address types and protocol families, then
its exception results for bad values would differ from those on .NET
(possibly breaking applications that relied on catching specific
But that's just my guess. The patch is a couple months old, so I'm not
even sure if it will apply correctly, just thought I'd show you where I
started when facing the same issue. Good luck.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2449 bytes
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100511/6e2e2684/attachment.obj
More information about the Mono-devel-list