8
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)
{
Содержание C381P J2ME
Страница 1: ...Technical Manual Version 01 00 Motorola C381p Handset J2ME Developer Guide ...
Страница 34: ...8 Network APIs 34 catch Exception ex hc i null Code Sample 3 HTTPS Connection ...
Страница 48: ...10 JSR 120 Wireless Messaging API 48 e toString Code Sample 5 JSR 120 Wireless Messaging API ...