title: Bluetoothlistener help
body: <p>I'm not very sure but for some reasons I can't use a BlueToothListener that receives string information.</p>
  <p>I tried following <a href="http://32feet.net/forums/t/1440.aspx" rel="nofollow noreferrer">this example</a>, and it doesn't seems to work.</p>
  <h3>Code Snippet</h3>
  <pre><code>private Guid Rffcomm = BluetoothService.RFCommProtocol; 
  private void btnConnect_Click(object sender, EventArgs e)
  {
      if (comboBox1.SelectedValue != null)
      {
          try
          {
              BluetoothClient btSender = null;
              btSender = new BluetoothClient();
              btSender.Connect(new BluetoothEndPoint(selectedAddr, Rffcomm));
              MessageBox.Show(&quot;1&quot;);
              StreamWriter swSender = new StreamWriter(btSender.GetStream());
              swSender.WriteLine(&quot;Test 1&quot;);
              //swSender.Flush();
              // swSender.Close(); // At first it worked, but after some tries, IOsocket exception keeps popping out.
          }
          catch (Exception se)
          {
              MessageBox.Show(se.Message);
          }
      }
  }
  
  void listening()
  {
      try
      {
          bool run = true; 
          BluetoothListener btl = new BluetoothListener(Rffcomm);
          btl.Start();
          while(run)
          {
              BluetoothClient btReceiver = btl.AcceptBluetoothClient();
              StreamReader srReceiver = new StreamReader(btReceiver.GetStream());
              String writeInfo = srReceiver.ReadLine();
              test = writeInfo;
              srReceiver.Close();
          }
          MessageBox.Show(test);
      }
      catch(Exception ex) { MessageBox.Show(ex.Message); }
  }
  
  private void button1_Click(object sender, EventArgs e)
  {
      // Start a new thread to deal with an incoming Bluetooth connection
      Thread t = new Thread(new ThreadStart(listening));
      t.Start();
  }
  </code></pre>