×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    86

    Help Regarding Socket programming in j2me

    HI,
    I am connecting to the webserver(Google,Yahoo).
    I wrote one socket program for connecting to those server through 80 port.
    I am able to send the request from browser(desktop) and getting the response from the server and displaying it in the browser(desktop).

    Now i want to install this application in mobile.After installing the application in the mobile,i need to go back to the browser in the mobile.
    can anyone tell me how to do this?Is it like running a background process?
    I dont have any idea about background process in j2me?

    Thanks a lot

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Help Regarding Socket programming in j2me

    hello,

    real "background" midlet process is something that will be introduced in future with MIDP 3.0,
    currently there is no real "background" midlet on nokia devices, some other manufacturers devices have "background" java midlets features:
    http://discussion.forum.nokia.com/fo...ght=background

    by the way:
    do you mean http connections? or sockets connections? if you haven't tried yet on real device when using socket connection to 80 (and 447/8080) port you will get SecurityException unless midlet is signed with 3rd party certificate (MIDP 2.0 security rule),

    regards,
    Peter

  3. #3
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    86

    Re: Help Regarding Socket programming in j2me

    hi
    thanks for your reply.
    Do u mean 3rd party certificate as verisign certificate for my application?

    Thanks a lot

  4. #4
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    86

    Re: Help Regarding Socket programming in j2me

    hi,
    I tried with my code to connect directly to 80 port and tried to access the google page.
    At that time,in my application the connection accepted message is displayed after that the google page not displayed in the browser(mobile).
    Can you tell me how to connect to 80 port?
    Do u have any sample codes to do so?

    Thanks a lot

  5. #5
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Help Regarding Socket programming in j2me

    hello,

    #1
    Verising is 3rd party certificate (not operator/manufacturer or self-signed certificate)

    #2
    I'm using HttpConnection to perform REST-full request to Google/Yahoo/other apis without any issue,
    you can use Get/Post/Head requests using HttpConnection, it uses 80 port by defaut as default http gateway on webservers,

    signing with 3rd party certificates when using 80/447/8080 ports is only required if you are using SocketConnection - that is persistant tcp/ip based connections for standard http ports,

    #3
    open source example of using public Google api is here:
    http://sourceforge.net/projects/gcalsync
    if you want to compare your code with existing implementations,

    hth,
    regards,
    Peter

    hth,
    regards,
    Peter

  6. #6
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    86

    Re: Help Regarding Socket programming in j2me

    hi
    thanks for your valuable suggestions and replies.

    Today i tried to port my application in Nokia 6630 mobile.
    I successfully installed the application.but the problem is im unable to connect to the proxy server but im getting the request from the mobile browser.
    The following is my code for sending the request to the proxyserver and getting back the response:

    s = (SocketConnection)Connector.open("socket://"+hostname+":"+port);
    /*OutStream to write the request to the proxy server*/
    OutputStream out = s.openOutputStream(); PrintStream outw = new PrintStream(out); outw.print(requestHeader +"\r\n"); /*Inputstream to read the response from the proxy server*/ InputStream in = s.openInputStream();
    /*writing the response in the browser */
    byte[] buffer = new byte[1024];
    int len;
    while((len = in.read(buffer)) > 0) {
    os.write(buffer, 0, len);
    }

    is my coding correct?or i need to change anything in my codings?
    This coding is working fine in emulator and displaying the correct output in the desktop browser.but in mobile it is not working?

    thanks a lot

  7. #7
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Help Regarding Socket programming in j2me

    hi,

    Your code seems just like any other code I've seen for sockets on microedition,

    have you considered:
    #1
    using either ip address or host name to see difference (ie XXX.XXX.XXX.XXX or domain.com)
    #2
    trying different APN when prompted in device?

    regards,
    Peter

Similar Threads

  1. problem in persistant socket connection
    By poms4symbian in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-03, 13:23
  2. Socket and thread issues with UI programming
    By mcloke74 in forum Symbian
    Replies: 3
    Last Post: 2005-06-30, 09:13
  3. Bluetooth Programming in J2ME with 6600
    By wing0custom in forum Mobile Java General
    Replies: 3
    Last Post: 2004-02-09, 17:09
  4. Bluetooth Programming in J2ME with 6600
    By wing0custom in forum Bluetooth Technology
    Replies: 1
    Last Post: 2004-02-06, 18:45
  5. Questions about Symbian OS socket programming
    By cs_lcmaa in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2002-12-09, 04:58

Posting Permissions

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