User guide

18
Chapter 3. Networking
Introduction
The Palm SDK contains a net library that provides network services, like TCP/IP, to
applications. With this library, an application on the Palm device can connect to any other
machine on a network using standard TCP/IP protocols. The API for this library is a
socket interface, modeled very closely on the Berkeley Sockets API.
The similarity between the Berkeley Sockets API and the net library is so close that the
Berkeley Sockets source code can be compiled for the Palm OS with minor-and
sometimes no-changes. As a result, porting networking code to the Palm OS is very
simple. The code can also be ported to any portable Unix-like platforms, like Agenda
VR3.
The code was developed on a Unix platform and then just compiled for Palm OS. Much
more sophisticated debugging tools are available in the Unix/Linux world than for Palm
OS.
Constraints
Currently, TCP/IP communication standard is available only via a serial or modem
connection. As mentioned in the previous chapter, IR communication is available only
via the serial port. This means that:
There cannot be IR communication and TCP/IP connection at the same time.
Therefore, the TCP/IPC connection starts only when there is data to transmit, or
when the user initiates a transfer. It terminates immediately after the data was
transferred.
After the TCP/IP connection is initiated, if any kinds of errors are encountered,
our application has to assure that it terminates the TCP/IP connection, in order to
unlock the resources, i.e. serial port.
The Client
Our Palm application executes a temperature-monitoring loop. While in this loop, the
serial port is used for IR communication with the board. There are 3 situations in which
the application can terminate IR communication and start a TCP/IP connection.
If the temperature is below or above certain thresholds (current_temp <
MIN_TEMP or MAX_TEMP < current_temp), the application sends a warning e-
mail message. After that, it waits until the temperature reaches values between the