You Are Here:

Community: Developer Discussion Boards

#1 Old How to determinate MIDP support Socket protocol in StreamConnection Class - 2003-04-09, 10:16

Join Date: Mar 2003
Posts: 55
Wah
Offline
Regular Contributor
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
Reply With Quote

#2 Old 2003-04-09, 12:20

Join Date: Mar 2003
Posts: 393
nmittal's Avatar
nmittal
Offline
Regular Contributor
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
Reply With Quote

#3 Old 2003-04-10, 08:21

Join Date: Mar 2003
Posts: 55
Wah
Offline
Regular Contributor
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
Reply With Quote

#4 Old check the exception message - 2003-05-13, 10:31

Join Date: May 2003
Posts: 9
fpony
Offline
Registered User
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...
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia