title: Android pairing does not work - "connection reset by peer"
body: <p>As the title explains I'm having a hard time sending some data via Bluetooth to my PC. I'm trying to establish a connection with my android phone as client and my PC as server. When I'm trying to actually establish a connection via BluetoothSocket.connect() my phone prompts for a pin. After entering it my PC also prompts for the same pin but before I can enter it, the connect() - method throws an IOException. I assume that the connect()-Method times out before I can enter the correct pin on my PC, but how can I get it to wait long enough for me to enter the PIN?</p>
  
  <p>EDIT: After Re-Pairing the PC with my Phone it worked, because the pairing dialog doesn't appear in my app anymore. If I unpair the PC and start my app, the pairing dialog pops up but disappears after several seconds and the socket throws an exception ("connection reset by peer"). Apparently the connection is reset before the pairing is done, but why?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>private void connectToDevice(BluetoothDevice device)
  {
      mBluetoothAdapter.cancelDiscovery();
      BluetoothSocket socket = null;
      try 
      {
          socket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-                        0000-  1000-8000-00805F9B34FB"));
      } 
      catch (IOException e) 
      {
          Log.e("HeliRemote", "Couldn't get socket.");
          return;
      }
      try 
      {
          socket.connect();
      } 
      catch (IOException e) 
      {
          try 
          {
              socket.close();
          } 
          catch (IOException e1) 
          {   
              Log.e("HeliRemote", "Couldn't close connection");
          }
          // That's the message I get in LogCat
          Log.e("HeliRemote", "Couldn't connect to Socket.");
          return;
      }
  
      Log.i("HeliRemote", "connected.");
  }
  </code></pre>
  
  <p>I would be glad if somebody could give me any good words of advice regarding the problem.</p>