×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    connection problems while using client server MIDlets with Real terminals

    Hi there!
    I have two MIDlets, one is working as client and other is working as Server. Ther are working perfectly in the emulators but when I am tryng to run them in the real phones they desn't work. I am using Nikia 6630.
    Here s the code for client:
    String serverUrl = sProtocol + sUrl + ":9001";
    System.out.println(serverUrl);
    socketConn = (SocketConnection) Connector.open(serverUrl);

    // Read data from server
    is = socketConn.openInputStream();


    while((ch = is.read()) != -1)
    {
    b.append((char) ch);
    }

    pParent.testCaseDoneEx(true, b.toString());

    } catch(Exception e){
    e.printStackTrace();}

    ===================================
    and this is code for Server:
    ss = (ServerSocketConnection)
    Connector.open("socket://:9001");
    //ticker shows terminl's IP
    pParent.setTicker(ss.getLocalAddress());
    try{
    sc = (SocketConnection) ss.acceptAndOpen();
    os = sc.openOutputStream();
    os.write("String from Terminal Server\n\n\n".getBytes());
    os.close();
    }catch(Exception e)
    {
    e.printStackTrace();
    }

    Odes anybody have any suggestion what is wrong?

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    20

    Re: connection problems while using client server MIDlets with Real terminals

    [QUOTE]Originally posted by Rumens
    [B]Hi there!
    I have two MIDlets, one is working as client and other is working as Server. Ther are working perfectly in the emulators but when
    I am tryng to run them in the real phones they desn't work. I am using Nikia 6630.

    I spent about three days figuring out the solution for exactly this kind of problem.
    I am using a 6600 and at least for my phone the secret is in flushing the stream after writing.

    sc = (SocketConnection) ss.acceptAndOpen();
    os = sc.openOutputStream();
    os.write("String from Terminal Server\n\n\n".getBytes());
    !!!
    os.flush();
    !!!

    os.close();
    /Roland

Posting Permissions

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