×

Discussion Board

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

    Sockets in MIDP 1.0

    Hi

    Im developing a J2ME Chat client and im using MIDP 1.0. I know that Socket connections are not implemented in MIDP 1.0 specifications. Of course if somebody try to compile a code with Socket object, it doesnt compile.

    Well for that reason im trying to use a Connector(url) and a StreamConnection. Something like this:

    try {

    String url = "socket://" + "200.74.214.103" + ":" + "6660";
    StreamConnection s = (StreamConnection)

    Connector.open(url);

    Client( s); //manage messages in s

    }
    catch (IOException ioe) {

    exception(ioe);
    }

    For me is another way to connect a chat server. I test the program in a different emulators (J2ME wireless toolkit, nokia emulator 60 series, palm emulator, motorola emulator) and it works. But if i run the program in a handset for example Nokia 3650 for GPRS, GTRAN phone, it doesnt work. Now i dont now if the problem is with the code or the implementation of gateways (celular network).

    Somebody can tell me if there is something wrong? I can use that in MIDP 1.0? Is there another way to do that, some suggestions?

    Thanks a lot.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    2
    You are in same problem as I am. Emulators works fine but actual mobile phone don't work because MIPD requires only HTTP support (And current Nokia phones doesn't support sockets).

    When I try to connect to server, I get IOException, which says:

    "The requested protocol does not exist socket://servernameort"

    (servername and port containing correct name and port)..

    I have tried to run this whit Nokia 6100...


    -Hannu B.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    2
    .. An idea...

    One way to oevercome this is to use HTTP gateway, simple Java or C/C++ program running on server which accepts your chat client connections and then forwards them to correct server and port whit _real_ sockets. Personally i don't like this because this make application server dependable. And if someone messes up in your chat it's not possible to trace up who did.. But this could work..

    -Hannu B.

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    36
    It (gateway) does. We use that in our own product.

    One benifit is that it can be used to reduce the size of the packets and even deal with phone disconnects in a more robust manner.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    19

    Why

    If you're about to write your own Socket-Server, it shouldn't be a problem to handle with Http-headers.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    31
    The good news is that "socket:" type StreamConnections actually do work on the 3650. One thing you should avoid, though, is reading and writing from/to the same SocketConnection in two different threads. This will actually freeze your MIDlet. (I tested that on a Nokia 3650, Firmware V. 3.16). silvano

Posting Permissions

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