×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    1

    Bluetooth aplication problem

    Hello

    I'm working for a project and I have created a client-server bluetooth application. I start up the server application and then connect the client to it.

    The server needs to validate little information from the client and then the client will drop the communication.

    Then it should be ready for another client to connect to it... so when the communication drops I start the connection again by calling acceptAndOpen(xxx) one more time... and so on

    Here's the problem, I'm able to connect the client twice, then the server application freezes...

    Here's some of the code I'm using:





    public void startConnection(){

    try {
    ld = LocalDevice.getLocalDevice();
    ld.setDiscoverable(DiscoveryAgent.GIAC);
    url = "btspp://localhost:"+uuid.toString()+";name="+ld.getFriendlyName();
    scn=(StreamConnectionNotifier)Connector.open(url);
    open();

    } catch (BluetoothStateException ex) {
    } catch (IOException ex){
    }
    }


    public void open(){

    try{
    sc=scn.acceptAndOpen();
    dis=sc.openDataInputStream();
    dos=sc.openDataOutputStream();
    recibir();
    } catch (BluetoothStateException ex) {
    ex.printStackTrace();
    } catch (IOException ex){
    ex.printStackTrace();
    }


    ublic void closeConnections(){
    try {
    if(dos!=null)dos.close();
    if(dis!=null)dis.close();
    if (sc!=null)sc.close
    } catch (IOException ex) {}


    open();
    }


    public void receive() {
    Thread t = new Thread() {
    public void run() {
    String mensajeRecibido = null;
    try {
    mensajeRecibido = dis.readUTF();
    //do something with the message
    receive();
    } catch (IOException e) {
    closeConnections();
    }
    }

    };
    t.start();
    }
    Last edited by ARGUELLOJULIO; 2008-05-19 at 20:08.

Similar Threads

  1. Bluetooth Service Discovery Problem
    By rwan067 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-03-18, 14:32
  2. Q: Problem with Nokia PC Suite and Bluetooth
    By Juha_74 in forum General Development Questions
    Replies: 0
    Last Post: 2007-03-13, 13:32
  3. Strange Problem with Bluetooth Connection
    By bigbadwolf in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2006-12-06, 09:51
  4. Bluetooth serviceDiscover problem Device Not Reachable
    By kashifqazi in forum Bluetooth Technology
    Replies: 1
    Last Post: 2006-10-13, 12:31
  5. Nokia SDK Bluetooth service re-discovery problem, Help Me!:(
    By tomsonxu in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-11-08, 07:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×