TCP Sockets
The
StreamConnection sc =
(StreamConnection)Connector.open(
“socket://www.motorola.com:8000”);
Although similar to HTTP, notice the required port number at the end of the remote address. In the previous protocols, those ports are well known and registered so they are not required, but in the case of low level sockets, this value is not defined. The port number is a required parameter for this protocol stack.
UDP Sockets
If networking efficiency is of greater importance than reliability, datagrams (UDP) sockets are also available to the application in much the same manner as other networking protocols. The Connector object in this case returns a DatagramConnection object, as is shown in the following example:
DatagramConnection dc = (DatagramConnection)Connector.open( “datagram://170.169.168.167:8000”);
Much like
Implementation Notes
As stated in the previous sections, the Motorola C370, C450, and C550 series of handsets supports some networking options. The networking options however are limited by both memory and bandwidth, which place hard restrictions on the applications. These limitations manifest themselves mainly in the number of simultaneous connections that can be opened.
Maximum number of sockets is 5 of any combinations of HTTP and UDP. Due to memory constraints, the C370, C450, and C550 can support only one secure session (i.e. if other application like Browser already opened a secure socket, a KJava midlet will get an IOException when it tries to open only one connection which is HTTP connection). If the maximum number of sockets is concurrently opened by the application and a sixth socket is requested, an exception is thrown to the calling application.