[Mono-dev] Non-TCP/IP socket access
Ivo Smits
Ivo at UFO-Net.nl
Fri Jul 22 12:04:29 EDT 2011
Op 22-7-2011 17:05, Andy Hume schreef:
> That was the most beautiful ugly thing I've seen in a long time. :-)
> Unfortunately I haven't managed to get it to work:
> 1) Try [DllImport("__Internal")] extern int _wapi_socket(..)
> Swallowed Exception: System.EntryPointNotFoundException: _wapi_socket
>
> 2) Try [DllImport("mono-2.0")] extern int _wapi_socket(..)
> Swallowed Exception: System.EntryPointNotFoundException: _wapi_socket
>
If I remember correctly, the class name including it's namespace may
need to be the same. I have used a similar 'hack' with the file I/O to
create an unbuffered stream I/O wrapper. I've used the
[MethodImplAttribute(MethodImplOptions.InternalCall)] attribute there;
just copy-pasted from the Mono sourcecode. Also, shouldn't the return
value be an IntPtr rather than an int?
However, looking at the mono code, there are no checks in the managed
part of the Socket construction. Did I miss anything, is it in the
unmanaged code perhaps? Have you tried to use the managed Socket
constructor, and optionally cast an integer value to the
AddressFamily/ProtocolType? You could then retrieve the socket handle
and make the bind/connect calls.
--
Ivo
More information about the Mono-devel-list
mailing list