Motorola C370 ユーザーズマニュアル

ページ / 86

Network API  
 
33 
- boolean timeout –  
An optional third parameter,  protocol may throw an 
IOException when it detects a time-out condition.
 
The time-out period for the TCP implementation on the Motorola C370, C450, and C550 
series of handsets is 20 seconds on read operation and about 45 seconds on write 
operation if the time-out flag is set to true. If the time-out flag is set to false, the time-out 
time is indefinite. The lingering time for closing sockets is 0 second (if the socket closed 
by the server the lingering time will be less than 100 ms). If a new socket is requested 
within this time frame and the maximum number of sockets opened has been reached (5 
sockets), then an IOException is thrown. 
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, etc.  The following chart details the prefixes that should be used for the 
supported protocols. 
Protocol 
URL Format 
HTTP 
http:// 
TCP Sockets 
socket:// 
UDP Sockets 
datagram:// 
 
HTTP 
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 to show implementation of HTTP: 
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”.