[ This chapter does not appear in the book. ]
The echoing client/server application in chapter B1 uses RFCOMM, a stream-based communications API which is implemented on top of the packet-based L2CAP. L2CAP segments the stream data supplied by RFCOMM into packets prior to transmission, and reassembles received packets into larger messages.
This chapter revisits chapter B1's echoing application, replacing the RFCOMM communication layer with L2CAP. The primary reason for doing this is to speed up the communication, by reducing the latency and avoiding the overheads involved in establishing a stream connection.
Another reason for moving to L2CAP is that JSR 82's L2CAPConnection class offers a ready() method which can be used to implement a polling server.
As a consequence, this chapter presents two L2CAP versions of the echoing application: the first uses threaded handlers very similar to those employed in chapter B1, while the second utilizes polling.
The changes required to move from RFCOMM to L2CAP, and from a threaded server architecture to one using polling are almost completely invisible to the user. The screenshots on this page show the threaded L2CAP server with its client.
Dr. Andrew Davison
E-mail: ad@coe.psu.ac.th
Back to my home page