| Reply | « Previous Thread | Next Thread » |
|
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 |
|
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 |
|
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 |
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|