Motorola C381P 用户手册

下载
页码 130

Network
 APIs  
 
32 
                } 
                while (bytes_read > 0); 
 
            } catch (Exception ex) { 
                   System.out.println("IO failed: "+ 
ex.getMessage()); 
            } 
            finally { 
                closeAllStreams(i); //clean up 
            } 
        } 
 
Code Sample 2 Socket Connection 
User Permission 
The user of the handset will explicitly grant permission to add additional network 
connections.  
HTTPS Connection 
Motorola implementation supports a HTTPS connection on the Motorola C381p handset. 
Additional protocols that will be supported are the following: 
•  TLS protocol version 1.0 as defined in 
http://www.ietf.org/rfc/rfc2246.txt
 
•  SSL protocol version 3.0 as defined in 
http://home.netscape.com/eng/ssl3/draft302.txt
 
 
The Code Sample 3 shows the implementation of HTTPS: 
HTTPS 
import javax.microedition.io.*; 
import java.io.*; 
import javax.microedition.midlet.*; 
… 
 
        try { 
            hc[i] = 
(HttpConnection)Connector.open(“https://” + url[i] + "/"); 
  
        } catch (Exception ex) { 
            hc[i] = null; 
            System.out.println("Open Failed: " + 
ex.getMessage()); 
        } 
 
        if (hc[i] != null) 
        {