O'Reilly logo

Wireless Java by Qusay H. Mahmoud

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 java.io and java.net 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 java.net 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: javax.microedition.io.Connector . If successful, these methods return ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required