title: SPP android/eclipse server, giving back socket closed error?
body: <p>I am trying to run a simple spp server with android and eclipse and it doesn't seem to be connecting is there competition for the UUID or? Also I am using the MAC address of my computer is that correct? </p>
  
  <p>ConnectTest Code on android</p>
  
  <p>Readout:</p>
  
  <pre><code>...In onCreate()...
  ...Bluetooth is enabled...
  ...In onStart()...
  ...In onResume...
  ...Attempting client connect...
  ...Sending Message to server...
  </code></pre>
  
  <p>Popup:</p>
  
  <pre><code>In onResume() and an exception occured during write: socket closed.
  </code></pre>
  
  <p>Eclipse sppserver code</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  
  import javax.bluetooth.*;
  import javax.microedition.io.*;
  
  /**
  * Class that implements an SPP Server which accepts single line of
  * message from an SPP client and sends a single line of response to the client.
  */
  public class SimpleSPPServer {
  
      //start server
      private void startServer() throws IOException{
  
          //Create a UUID for SPP
          UUID uuid = new UUID("1101", true);
          //Create the servicve url
          String connectionString = "btspp://localhost:" + uuid +";name=Sample SPP Server";
  
          //open server url
          StreamConnectionNotifier streamConnNotifier = (StreamConnectionNotifier)Connector.open( connectionString );
  
          //Wait for client connection
          System.out.println("\nServer Started. Waiting for clients to connect...");
          StreamConnection connection=streamConnNotifier.acceptAndOpen();
  
          RemoteDevice dev = RemoteDevice.getRemoteDevice(connection);
          System.out.println("Remote device address: "+dev.getBluetoothAddress());
          System.out.println("Remote device name: "+dev.getFriendlyName(true));
  
          //read string from spp client
          InputStream inStream=connection.openInputStream();
          BufferedReader bReader=new BufferedReader(new InputStreamReader(inStream));
          String lineRead=bReader.readLine();
          System.out.println(lineRead);
  
          //send response to spp client
          OutputStream outStream=connection.openOutputStream();
          PrintWriter pWriter=new PrintWriter(new OutputStreamWriter(outStream));
          pWriter.write("Response String from SPP Server\r\n");
          pWriter.flush();
  
          pWriter.close();
  
          streamConnNotifier.close();
  
      }
  
  
      public static void main(String[] args) throws IOException {
  
          //display local device address and name
          LocalDevice localDevice = LocalDevice.getLocalDevice();
          System.out.println("Address: "+localDevice.getBluetoothAddress());
          System.out.println("Name: "+localDevice.getFriendlyName());
  
          SimpleSPPServer sampleSPPServer=new SimpleSPPServer();
          sampleSPPServer.startServer();
  
      }
  }
  </code></pre>
  
  <p>readout:</p>
  
  <pre><code>Address: A45E60EB3CE8
  Name: DESKTOP-QD8I9B1
  
  Server Started. Waiting for clients to connect...
  </code></pre>