Java Reference
In-Depth Information
The link between the Connection interfaces and reality is a class called
javax.microedition.io.Connector . The basic idea is that you pass a connection string to one of
Connector 's static methods and get back some Connection implementation. A connection string
looks something like a URL, but there are various other possibilities. The connection string
socket://apress.com:79 might open a TCP/IP connection to apress.com on port 79, then
return a StreamConnection implementation. Chapter 9 used a FileConnnection from the JSR 75
optional package to access file systems.
MIDP 2.0 requires support of Hypertext Transfer Protocol (HTTP) connections. You pass
an HTTP URL to Connector and get back an implementation of HttpConnection . Mandatory
support for HTTPS connections (secure HTTP) is also required by MIDP 2.0. There are also
standardized connection strings for several types of connections. We'll discuss these later in
this chapter (see the sections following “Making a Connection with HTTP GET”).
HttpConnection 's methods are detailed in Figure 10-2. Most of the methods in HttpConnection
have to do with details of HTTP, which we won't cover here. We'll cover everything you need to
know to connect to a server here, including both GET and POST requests. If you need to dig
deeper, you can read RFC 2616 (one of the Internet standards documents), available at
http://ietf.org/rfc2616.html. Note that MIDP uses a subset of the full HTTP 1.1; only the
GET, POST, and HEAD commands are required.
Figure 10-2. The HttpConnection interface
Search WWH ::




Custom Search