[Mono-dev] Non-TCP/IP socket access

Andy Hume andyhume32 at yahoo.co.uk
Fri Jul 22 09:00:36 EDT 2011

> From: mono-devel-list-bounces at lists.ximian.com 
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf 
> Of Robert Jordan
> Sent: 22 July 2011 12:43
> To: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Non-TCP/IP socket access
> On 22.07.2011 13:08, Andy Hume wrote:
> > Presumably I can't convert my fd to a wapi handle somehow...  So is 
> > that plan not going to work? :-,(
> It won't work. The whole socket machinery assumes type 
> AF_UNIX or AF_INET. If you set a fd of some other address 
> family type, a lot of nasty things could happen if this check 
> wasn't there.
> Get/SetSocketOptions, Local/RemoteEndPoint etc. simply don't 
> cope with other AF types. They would return garbage at best.
I actually don't need to call any of those functions -- and if I were I
could just P/Invoke them...[1] :-,(  

The bit I obviously don't want to have to write myself is anything to do
with I/O.  That's a huge amount of difficult work and its all there and
working in Mono and would work for my (SOCK_STREAM) socket if I could
just create the socket somehow. :-,(

All I need is that wapi handle...[2]  Do we think it's impossible to
access it.



[1]  Actually, since
ced0 the restriction on the types of sockaddr/EndPoint has beem removed
in the managed code.  Now the Prototype Pattern is used to allow the
managed code to return arbitrary sub-types of EndPoint class.  In
get_LocalEndPoint/RemoteEndPoint/etc(?) the EndPoint previously used by
the caller for Bind/Connect is used as the prototype to convert the byte
array returned from the call to getpeername etc, e.g.
     return seed_endpoint.Create (sa);

So the restriction in the runtime could be removed too.  That's what the
behaviour is on MSFT (both desktop and NETCF).  I have working Bluetooth
and IrDA sockets there.  So it's a shame they're blocked on Mono.  But
that's perhaps for a later discussion...

[2] Or for sockets on Mono _not_ to block access for a different family
values.  And then I could use the I/O functions at least([1]).

More information about the Mono-devel-list mailing list