Cannot Connect more than 2 devices

Topics: Bluetooth - Microsoft
Feb 12, 2013 at 10:23 AM
Hello, i have this little problem :

I have an Android App and a windows form connecting by Bluetooth.
This works fine with one Mobile, when i try to connect with another Android device, theres no chance to connect, but with the first one is ok over and over again.

I dont know if the service that i create still open and is only for one mobile connection.

I start a BTListener and then i run a thread capturing the Client and when data is sending/reciving i close that client and start AcceptClients Again.

Sorry for my english.
Thanks a lot.
Feb 12, 2013 at 10:49 PM
There should be no problem with multiple devices connecting (even at the same time) to a BluetoothListener. You'd just need to arrange your code so that AcceptBluetoothClient is being called even when anuther connection is still open. Perhaps fire off each connection into a new thread.
void AcceptConnections()
   while(!quit) {
    var cli = _lsnr.AcceptBluetoothClient();
    ThreadPool.QueueUserWorkItem(Connection_Runner, cli);

void Connection_Runner(object state)
  var cli = (BluetoothClient)state;
  var peer = cli.GetStream();
  byte[] buf = new byte[1024];
  buf[0] = (byte)'a'; buf[1] = (byte)'b'; buf[2] = (byte)'c';
  peer.Write(buf, 0, 3);
  int readLen = peer.Read(buf, 0, buf.Length);
Feb 13, 2013 at 8:19 AM
Thanks you Alan, i ll change my code again, i have my AcceptBluetoothClient() inside the Thread, maybe that is my problem.
I ll try to adapt my code and ll tell you the results.

Thanks again!