×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    6

    opening a socket connection

    I am working on the msn protocol to make a msn client for the java enabled mobile devices using j2me. In order to communicate with the msn servers, i need to make a socket connection to them. On the emulator(that comes default with the j2me wireless toolkit) my application works perfectly alright. But i am facing problems when i actually put it to the device(nokia 3650). The problem that i get is with opening a socket connection and the corresponding input and output streams ON THE DEVICE. The code that i am using to open the connection is

    /*OPENING A SOCKET CONNECTION*/
    StreamConnection connection = (StreamConnection)Connector.open(URL,Connector.READ_WRITE);

    /*OPENING A OUTPUT STREAM*/
    DataOutputStream dos = connection.openDataOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(dos);

    /*OPENING A INPUT STREAM*/
    DataInputStream in = sc.connection.openDataInputStream();
    InputStreamReader isr = new InputStreamReader(in,"UTF-8");

    Keep in mind that these work perfectly alright on the emulator and other vendor's socket based application are working on my mobile device(nokia 3650). Is there any other way to perform this socket connection thing or what can the possible error be in my code. if u have made any socket based application, can u please send me the code for opening the connection and opening input and output streams. My email address is bhatti81@yahoo.com
    I am really stuck, plz help me out.I'll be really really thankful.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Location
    shanghai
    Posts
    44
    There is no socket support at Nokia3650
    But the j2me wireless toolkit support socket
    so your code can run success on j2me wireless toolkit emulate.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    1
    There IS socket support in Nokia3650, but it's undocumented
    I sure had problems along the way, but finally I got it working. Make sure that your GPRS connection is correct as well and some operators may allow port 80 only, so be observant about that.

    Here's some code u guys could try:

    String url = "socket://" + SERVER_ADDRESS + ":" + SERVER_PORT;

    connection = (StreamConnection) Connector.open(url,Connector.READ_WRITE,true);

    out = new DataOutputStream(connection.openOutputStream());
    in = new DataInputStream(connection.openInputStream());

    When writing output:
    out.writeByte(writeByte);
    out.flush();

    When reading input:
    readedByte = in.readByte();

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    28

    to niklashed

    dear niklashed :
    can you give your code that can be run on real phone 3650?thanks!

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    28
    i solve the problem,when the connection is ok,press the
    navigatorbotton downward,then ,the text content appeared.
    thanks,guys.

Posting Permissions

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