Chapter 7. Networking
Way back in Chapter 1, we briefly introduced the CLDC Generic Connection Framework. Let’s quickly review why it was necessary to create an entirely new networking library for the CLDC.
packages of the
J2SE are not suitable for handheld devices with a small memory
footprint, for the following reasons:
Device manufacturers who work with circuit-switched networks require stream-based connections such as the Transport Control Protocol (TCP), which is a connection-oriented protocol.
Device manufacturers working with packet-switched networks require datagram-based connections such as the User Datagram Protocol (UDP), which is a connectionless protocol.
Other handheld devices have specific mechanisms for communications.
All this variation makes designing networking facilities for the CLDC
quite a challenge. This challenge has led to the design of a set of
related abstractions that can be used at the programming level
instead of using different abstractions for different forms of
communications. For example, the J2SE
package provides a set of related abstractions in the form of over 20
networking classes, including
DatagramSocket. With the CLDC, however, we need to
go a step further to save space.
In the Generic
Connection Framework, all connections are created using the static
methods from a single class:
. If successful, these methods return ...