Motorola Inc. | i88s J2ME Developers’ Guide |
Applications requesting a network resource for any protocol must use one of the three methods above. The URL is the distinguishing argument that determines the difference between HTTP, UDP, Serial, etc. The following chart details the prefixes that should be used for the supported protocols.
Table 2-1: Supported Protocols on the i88s Phone
Protocol | URL Format |
HTTP | http:// |
HTTPS | https:// |
TCP Sockets | socket:// |
SSL Secure Sockets | ssocket:// |
Server Sockets | serversocket:// |
UDP Sockets | datagram:// |
Serial Port | comm:0; |
2.2.1HTTP
The HTTP implementation follows the MIDP 1.0 standard. The Connector.open() methods return a HttpConnection object that is then used to open streams for reading and writing. The following is a code example:
HttpConnection hc = (HttpConnection)Connector.open(“http://www.motorola.com/”);
In this particular example, the standard port 80 is used, but this parameter can be specified as shown in the following example:
HttpConnection hc = (HttpConnection)Connector.open(“http://www.motorola.com:8080”);
The other static Connector methods work in the same manner, but they provide the application additional control in dealing with the properties of the connection. By default, HTTP 1.1 persistency is used to increase efficiency while requesting multiple pieces of data from the same server. In order to disable persistency, set the “Connection” property of the HTTP header to “close”.
2.2.2HTTPS
The HTTPS implementation follows the MIDP 1.0 standard, save for the security aspects. The Connector.open() methods return a HttpConnection object that is then used to open streams for reading and writing. The following is a code example:
HttpConnection hc = (HttpConnection)Connector.open(“https://www.motorola.com/”);
Version 1.0 - Page 16