我有一个设备通过蓝牙主动连接到计算机。从我的 C#.NET 应用程序中,我希望断开设备,以便计算机不再连接到设备。
我该怎么做呢?
我猜这与找到合适的套接字并断开该套接字有关吗?(但这纯粹是冒险猜测,因为我对 Socket 连接一无所知。)
有任何想法吗?
我有一个设备通过蓝牙主动连接到计算机。从我的 C#.NET 应用程序中,我希望断开设备,以便计算机不再连接到设备。
我该怎么做呢?
我猜这与找到合适的套接字并断开该套接字有关吗?(但这纯粹是冒险猜测,因为我对 Socket 连接一无所知。)
有任何想法吗?
根据我对蓝牙(Java 和 Perl,不是专门针对 c#)的经验,当您关闭输入/输出流时,连接开始断开。然后最后一剂毒药是关闭插座。/$0.02
来自 MSDN blog on Bluetooth Device Development using C#:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.WindowsMobile.SharedSource.Bluetooth;
namespace ToggleBluetooth
{
class Program
{
static void Main(string[] args)
{
BluetoothRadio brad = new BluetoothRadio();
if (brad.BluetoothRadioMode == BluetoothRadioMode.Off)
brad.BluetoothRadioMode = BluetoothRadioMode.On;
else
brad.BluetoothRadioMode = BluetoothRadioMode.Off;
}
}
}