Java Reference
In-Depth Information
Server sockets
Secure sockets
Serial port access.
In the remainder of this chapter, we focus on the networking protocols
from the GCF. The local connectivity protocol (serial port access) is similar
in nature to the network protocols, but its connection string depends on
the target handset model, therefore you must study it separately.
2.6.1 HTTP and HTTPS Support
To open an HTTP connection we use the method
with a URL of the form . Code to open an Http-
Connection and obtain an InputStream would look something like
try {
String url = "";
HttpConnection conn = (HttpConnection);
InputStream is = conn.openInputStream();
} catch(IOException ioe) { ... }
Under the MIDP security model, untrusted MIDlets can open an HTTP
connection only with explicit user confirmation. Signed MIDlets that
require access to an HTTP connection must explicitly request permission:
MIDlet-Permissions:, ...
Opening an HTTPS connection follows the same pattern as a normal
HTTP connection, with the exception that we pass in a connection
URL of the form and cast the returned
instance to an HttpsConnection object, as in the following example:
try {
String url = "";
HttpsConnection hc = (HttpsConnection);
InputStream is = hc.openInputStream();
Search WWH ::

Custom Search