newbi in jme 0 Newbie Poster

Hello to all
My Program is a connect between the mobile and laptop via Bluetooth,And send msg from mobile to the laptop, and vice versa via Bluetooth the server located on the laptop I used JSE with using BlueCove, and a client on the mobile phone using j2me both develop using Netbeans 6.8 I have a problem that the server appears the message sent from phone after I close the MIDlet in phone when it should do this when I press the name of device found by device discovered
pc recive the msg after closing the MIDlet
I dont know what is the wrong
can one of u check the program and find the error plz
I would be very thankful to u

private void doServiceSearch(RemoteDevice device) {
      int[] attributes = {0x100, 0x101, 0x102};
      UUID[] uuids = new UUID[1];
      uuids[0] = new UUID(0x1101);
      try {
      agent.searchServices(null, uuids, device, this);
      } catch (BluetoothStateException e) {
      Alert alert1 = new Alert("Error");
      alert1.setString(e.toString());
      display.setCurrent(alert1);
      }
      }
     public void servicesDiscovered(int transID,ServiceRecord[] record) {
     for (int i = 0; i < record.length; i++) {
   String   m_strUrl = record[i].getConnectionURL(ServiceRecord.
         AUTHENTICATE_ENCRYPT, false);
     }
     connectionURL= record[0].getConnectionURL(ServiceRecord.
     NOAUTHENTICATE_NOENCRYPT, false);
     }
    public void serviceSearchCompleted(int transID, int type) {
        switch (type) {
        case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
      try{
StreamConnection conn = (StreamConnection) Connector.open(connectionURL);
OutputStream output=conn.openOutputStream();
InputStream input = conn.openInputStream();
// send msg to server=write
String msg = " Hello server ";
output.write(msg.getBytes());
output.flush();
output.close();
conn.close();
// recive msg from server= read

}catch (Exception e) {
    }
        break;
        case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
        break;
        case DiscoveryListener.SERVICE_SEARCH_ERROR:
        break;
        case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
        break;
        case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
        break;
        }    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.