Can I use C # to write a client PC from a PC with Socket?

I am trying to write a PC client with Bluetooth that can perform some simple interactive actions with an Android device via Bluetooth. Then I found out that you can use Windows Socket programming to achieve, however, when I try to create a new socket, this link is a link .

Here are my error codes:

Socket tempSocket = new Socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); 

So here is my question: does this mean that I have to use C ++ for this? If not, how to create a new socket with bluetooth-type under C #?

+5
source share
1 answer

you can use http://32feet.codeplex.com/ to connect bluetooth here is a simple demo to discover new devices:

 List<Device> devices = new List<Device>(); BluetoothClient bc = new BluetoothClient(); BluetoothDeviceInfo[] array = bc.DiscoverDevices(); int count = array.Length; for (int i = 0; i < count; i++) { Device device = new Device(array[i]); devices.Add(device); } 

refrence: http://blogs.microsoft.co.il/shair/2009/06/21/working-with-bluetooth-devices-using-c-part-1/

The 32-bit documentation is good enough to watch (samples are in vb, but its .net is easy to convert to C #)

0
source

Source: https://habr.com/ru/post/1206046/


All Articles