Documentation  |   Table of Contents   |  < Previous   |  Next >   |  Index

14    Introduction to Sockets on Palm OS

Low-Level Communications

Exploring Palm OS®

Overview ^TOP^

Whereas previous versions of Palm OS® used a proprietary API for handling network connectivity, Palm OS Cobalt introduces the standard 4.3BSD Sockets API. Applications that use the old Netlib API will continue to work, but it is not possible to use the Palm OS Cobalt SDK to compile software to use the Netlib API. Applications designed to run on Palm OS Cobalt must be modified to use the Sockets API.

This API is provided as two elements:

  • A socket shared library that exports BSD socket functions for system services and applications.
  • A STREAMS module that performs TPI messaging adaptation and contains socket states.

NOTE: If you need to develop a 68K application using the Netlib API, your application should be built against the Palm OS Garnet SDK.

Unsupported Sockets Features ^TOP^

While the Palm OS Sockets API is almost totally compatible with the 4.3BSD Sockets API, there are three key differences:

AF_UNIX and PF_UNIX Unsupported ^TOP^

Palm OS does not support the AF_UNIX address family and the PF_UNIX protocol family, since it's not UNIX.

No socketpair() Function ^TOP^

The socketpair() function is not provided by Palm OS.

No UNIX-Style Asynchronous Features ^TOP^

Palm OS does not support UNIX-style asynchronous signals, options, or flags.

Architecture of the Sockets Support System ^TOP^

The Sockets API for Palm OS is implemented as an I/O Subsystem (IOS) module. It's implemented in a shared library that translates 4.3 BSD Sockets API calls into IOS STDIO function calls. This architecture is shown in easily-digestible diagram form in Figure 14.1.

Figure 14.1  Architecture of sockets on Palm OS

Protocol Mapping ^TOP^

The Sockets API determines the name of the device to open when request to open a particular socket is processed. The device that gets opened must build a TPI-compliant stream. Its name is derived from the family/domain, type, and protocol given in the socket() call. The device name is constructed using the following C code:

sprintf(device_name, "SX%02x%02x%02x", domain, 
type, protocol);