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.

The and 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 Socket, ServerSocket, and DatagramSocket. With the CLDC, however, we need to go a step further to save space.

Generic Connections

In the Generic Connection Framework, all connections are created using the static open( ) methods from a single class: . If successful, these methods return ...

Get Wireless Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.