1 Reply Latest reply: Mar 31, 2011 3:19 PM by DrClap RSS

    J2ME bluetooth client/server application (emulator only)

    852034
      Hello.

      I am writing application that will be a bluetooth chat application. Anyone can create a chat room and others can join that room. There can be many rooms.

      So I have a problem. I need the server (creator of the room), to be able to handle many connections simultaneously. The client first get a list of rooms by checking all the devices. Now I can create as many rooms as I want from many instances (emulators) of the application as I want, and when I run one client, he checks for rooms, and he get the correct list. If I run another client, it seems that he can't connect to any device, so the list is empty. IF I kill the first client, then check for rooms on the second client, it works well.

      I am closing every connection on both sides. This is the server code:

      while(!stopServer)
      {
      conn = null;
      System.out.println("waiting...");
      try{conn=mServerNotifier.acceptAndOpen();System.out.println("accepted...");}
      catch(Exception e) {System.out.println("err");continue;}

      if(conn!=null) {
      RequestProccesor rp=new RequestProccesor(conn);
      Thread t=new Thread(rp);
      t.start();
      }

      I am working with Netbeans 6.9.1 and Wireless toolkit 2.5.2. I need this to work only in emulator. RequestProccesor is my class, and it is checking what the client wants and if it wants the name of the room, it sends the name and closes the connection. The server should wait for other connections asynchronously.

      The second client reports error when checking for services on the discovered devices.
        • 1. Re: J2ME bluetooth client/server application (emulator only)
          DrClap
          849031 wrote:
          So I have a problem... If I run another client, it seems that he can't connect to any device, so the list is empty. IF I kill the first client, then check for rooms on the second client, it works well.
          I assume this is the issue you wanted to discuss? It's pretty hard to discuss it, unless you know something about the checking-for-rooms process. And so far, you're the only one who knows anything about it. Beyond the fact that it doesn't do what you want it to do, that is.