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 13. UDP Sockets

So far we have worked with stream sockets, based on the TCP protocol. TCP and stream sockets provide a convenient programming model for network communications. The developer is insulated from any issues of network reliability; the TCP stack automatically handles connections and guaranteed packet delivery. This programming convenience comes at the cost of protocol overhead.

This overhead becomes prohibitive as the packets of data get smaller. In Chapter 11, I discuss the Nagle algorithm, which allowed the batching of small packets of data into larger packets. This reduces overhead by sharing it among several packets, rather than each packet repeating the overhead.

In this chapter, I discuss the User Datagram Protocol (UDP), a lightweight alternative to TCP that dispenses with the connection semantics. We also examine the Daytime Protocol, which is available over either TCP or UDP, and we will implement a Daytime application.

What Is UDP?

The User Datagram Protocol is a layer on top of IP that provides an addressing scheme identical to the one used in TCP. A UDP address consists of the host’s IP address and service port number. Applications access UDP sockets with the same functions as TCP sockets.

What Is a Datagram?

A datagram is a block of data. The application may impose some structure on some or all of this data; UDP views it as an indivisible block of data. Datagrams must be sent complete in a single packet. And they are read as they were sent. The data ...

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