Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor Wah's Avatar
    Join Date
    Mar 2003
    Posts
    55
    Hi all,

    My J2ME application either connect to server by Socket or HTTP connection. I want the application can query MIDP when it starts up. If MIDP support Socket protocol in StreamConnection class the application uses Socket, otherwise it uses HTTP. Is there any API or method to do this query? Anyone has do the similar checking?

    Thanks
    Wah

  2. #2
    Regular Contributor nmittal's Avatar
    Join Date
    Mar 2003
    Posts
    393
    Try creating and opening a Connection using either protocols and if an exception is thrown then in the handler use the other protocol.

    try{

    connSock = (SocketConnection)Connector.open("socket://..")

    } catch(ConnectionNotFoundException e){ //conn cant be made or protocol unsupported

    connHttp = (HttpConnection)Connector.open("http://...");

    } catch (Exception e){} //some other I/O error or invalid param

    [N]/Forum Nokia

  3. #3
    Regular Contributor Wah's Avatar
    Join Date
    Mar 2003
    Posts
    55
    nmittal,

    Thanks for your reply.

    I wonder the exception ConnectionNotFoundException cannot resolve the reasons:

    1. Network no available.
    2. URL or IP address is not exist
    3. protocol not support


    Any others method?

    Regards
    Wah

  4. #4
    Registered User fpony's Avatar
    Join Date
    May 2003
    Posts
    9
    You should catch the IOException and check it's message (e.getMessage()) whether it contains things like "requested protocol does not exist" or "unsupported protocol" etc...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved