O'Reilly logo

Palm OS Network Programming by Greg Winton

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 4. Development Tools

There are many different development tools that allow you to write Palm applications, ranging from 68K assemblers to sophisticated forms packages. There are several flavors of Basic and a growing number of Java virtual machines. Still, most applications, including the examples in this book, are written in C or C++.

There are two C/C++ development environments: Metrowerks CodeWarrior and the Free Software Foundation’s PRC tools. CodeWarrior is available for Mac OS and Windows; the PRC tools are supported on Windows and Linux. Both toolsets include resource compilers and source-level debuggers. The Palm OS Emulator is a crucial tool in the development of Palm OS applications in general, and Palm OS network applications in particular. Mochasoft’s MochaPPP is useful for testing Palm OS network applications, though not the ones in this book, ironically. This chapter discusses these tools in depth.

Development Tools

The tools for developing network applications are the same as for developing standalone applications. This book assumes that the developer is familiar with the basics of developing Palm OS applications with either the CodeWarrior or PRC tools, and debugging these applications with the Palm OS Emulator. If not, Neil Rhodes and Julie McKeehan’s excellent book, Palm Programming: The Developer’s Guide (O’Reilly & Associates), provides a superior introduction to these and other Palm OS development issues.

CodeWarrior for Palm OS

The original Palm operating system was developed on the Macintosh using Metrowerks CodeWarrior; this was the only development environment for the Pilot 1000. Since then, CodeWarrior has been ported to Windows, and, after several releases, the Windows version has achieved the stability and usability that Macintosh developers have long enjoyed.

CodeWarrior is the tool of choice for most commercial Palm OS application developers, and is the “official” development environment. This commercial arena allows you to create C and C++ Palm applications, shared libraries, and code resources on either the Windows or Macintosh platforms. It provides an Integrated Development Environment (IDE), in which you can edit your code, create user interface resources, compile and link the project, and debug the application directly on the Palm OS Emulator (POSE). We discuss POSE later in this chapter.

CodeWarrior’s straightforward installation process, graphical user interface, and integration with POSE eases the development of Palm applications, especially for developers uncomfortable with makefiles, command-line interfaces, and the Unix flavor of the PRC tools.

PRC Tools

Before CodeWarrior was ported from the Macintosh to Windows, there was no way to develop for the Palm platform on Windows or Unix. Volunteer programmers leveraged the Free Software Foundations GNU `C’ Compiler (GCC) to create the GNU PalmPilot SDK, which allows Palm application development on these desktop platforms. This toolset is now known as PRC Tools and is maintained, in part, by resources from Palm, Inc.

PRC Tools is a free, open source collection of tools that support Palm OS development. In addition to GCC, it includes a resource compiler and source-level debugger. Several third-party IDE’s and graphical resource editors have been released to ease development with these tools.

This toolset presents several challenges in Palm application development. First, the user must download, install, and configure the tools, which is not for the faint of heart. The current PRC Tools release cannot build applications bigger than 64K. The developer should be comfortable with command-line tools and makefiles, although IDE’s have emerged that hide this somewhat. Being an open source project, at times there have been conflicts over the “true” development chain for these tools.

On the plus side, these tools are free. Developers comfortable with makefiles can create sophisticated build scripts to easily build a variety of target Palm applications. And if you prefer Unix, this is the only tool available. If, on the other hand, you use a Macintosh, these tools are not available at all.

Palm OS Platform SDK

The Palm OS Platform SDK provides access to the Palm OS for C and C++ application development. The SDK does not include a build environment, and must be used in conjunction with one of the C/C++ development environments discussed previously. An older version of the SDK ships with the Metrowerks CodeWarrior package. The latest version of this library can be downloaded from the Palm OS web site. The PRC tools do not come with the SDK; instead it must be downloaded from the Palm OS web site.

The examples in this book were all built with Version 3.5 of the SDK. Our applications could have been built with any version of the SDK, at least as far as the networking code is concerned. There have been few changes to the Net Library since its introduction in Version 2.0. Most of these changes have been internal to provide support for wireless networking. The latest version of the Palm OS SDK is 4.0, and contains the latest headers, libraries, and tools for Palm OS platform development on Windows, Mac OS, or Unix.

The SDK provides two programming interfaces to the network protocol stack. The Net Library is the native Palm OS network programming interface and the Berkeley Sockets programming interface is implemented on top of this as a “glue.”

Net Library

The Net Library is the native API for building networking applications on the Palm OS platform. This API and related structures and constants are declared in NetMgr.h. The Net Library API is loosely based on the Berkeley Sockets API, with allowances made for the Palm execution environment. Specifically, all Net Library functions take three parameters that are not required by Berkeley Sockets: the Net Library reference number, a timeout, and an out-parameter for reporting errors. Chapter 5 through Chapter 13 explore the Net Library API, including these extra parameters. Under Berkeley Sockets, all errors are reported in the global variable errno. The Net Library passes a parameter for errors to avoid the use of globals.

Berkeley Sockets “Glue”

The Berkeley Sockets “Glue” allows experienced network application developers to use familiar functions instead of the Net Library API. The majority of functions a developer would use are implemented as macros in the header file, Sys_Socket.h. For these functions, there is no overhead in using the Glue. A few others, notably the name resolution functions and the select function, require a glue wrapper, which is implemented in the library file, NetSocket.c. Both Sys_Socket.h and NetSocket.c are distributed with the Palm OS SDK.

As we discuss in Section 4.2, the debugging and connection options available for the device or emulator are distinctly limited. Using the Berkeley Sockets Glue, you can develop and debug the networking logic of your application on a desktop platform, where there are lots of connection options and powerful debugging tools. Once you get the networking logic working, you can port it easily to the Palm. This approach is covered in Neil Rhodes and Julie McKeehan’s Palm Programming: The Developer’s Guide.

Greg’s Palm OS Library

GLib is a collection of utility functions that were developed in the course of writing this book. These functions hide the details of Palm application development so we can focus on network development. The source for both this library and the examples are available at the O’Reilly FTP site. As a general purpose library, GLib is not ready for prime time. There are many hidden limitations, assumptions, and shortcuts that are safe only in the context of the applications developed in this book.

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