You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To solve problems related to creating sockets for Bluetooth in NET Core, you can use the constructor System.Net.Sockets.Socket that accepts an instance of the SafeSocketHandle class: public Socket(SafeSocketHandle handle);
The Handle is created using the native method, and all other work is successfully performed by NET Core sockets.
Here is an example of a modified Linux Socket class for Linux (similar to Win32):
public LinuxSocket() : base(CreateSocket()) { }
private static SafeSocketHandle CreateSocket()
{
if (Environment.OSVersion.Platform != PlatformID.Unix)
throw new PlatformNotSupportedException("Linux library used on non-Linux OS.");
int handle = NativeMethods.socket((AddressFamily)BluetoothEndPoint.AddressFamilyBlueZ, SocketType.Stream, BluetoothProtocolType.RFComm);
if (handle == -1)
ThrowOnSocketError(handle, true);
return new SafeSocketHandle((IntPtr)handle, true);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
To solve problems related to creating sockets for Bluetooth in NET Core, you can use the constructor
System.Net.Sockets.Socket
that accepts an instance of the SafeSocketHandle class:public Socket(SafeSocketHandle handle);
The Handle is created using the native method, and all other work is successfully performed by NET Core sockets.
Here is an example of a modified Linux Socket class for Linux (similar to Win32):
Beta Was this translation helpful? Give feedback.
All reactions