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

Andy Hume andyhume32 at yahoo.co.uk
Fri Jul 22 07:08:01 EDT 2011


I have a project that needs access to Linux Bluetooth sockets from Mono.  Miguel previously suggested that I would have to manually P/Invoke to socket (and connect, bind, getpeername, etc) and use Reflection to set the fd value returned by the socket call into the "socket" field in the Socket class.

I've implemented that but I get a ENOTSOCK on any access to Socket's methods/properties.  For example:
   System.Net.Sockets.SocketException: The descriptor is not a socket
     at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x000af] in /usr/src/packages/BUILD/mono-2.8/mcs/class/System/System.Net.Sockets/Socket.cs:2410 
   ...

Which is presumably due to the following (_wapi_recvfrom in sockets.c).
	if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
		WSASetLastError (WSAENOTSOCK);
		return(SOCKET_ERROR);
	}

Presumably I can't convert my fd to a wapi handle somehow...  So is that plan not going to work? :-,(

Thanks
Andy



More information about the Mono-devel-list mailing list