The Daytime Protocol

The Daytime allows clients to query servers for the current date and time. This is an extremely simple protocol, supported on both TCP and UDP. RFC 897 defines the UDP based Daytime service as:

... a datagram based application on UDP. A server listens for UDP datagrams on UDP port 13. When a datagram is received, an answering datagram is sent containing the current date and time as a ASCII character string (the data in the received datagram is ignored).

The Daytime server listens for incoming UDP datagrams on port 13. When it receives a datagram, it responds with a datagram containing the current date and time. The only formatting rule for this datagram is that it “should be just one line.”

Tip

In the TCP version of the Daytime Protocol, the client opens a connection to the server. The server sends the date and time as an ASCII string and closes this connection. When the client receives this string, it shuts down and closes the socket.

Our Daytime server responds to incoming datagrams with an ASCII string containing the day, date, and time. The format of this string is:

WWW_MMM_DD_YYYY_hh:mm:ss

The elements of this string are summarized in Table 13-1.

Table 13-1. Date and time formatting

Code

Meaning

WWW

First three letters of the weekday name: “Mon,” “Tue,” “Wed,” “Thu,” “Fri,” “Sat,” or “Sun”

MMM

First three letters of the month name: “Jan,” “Feb,” “Mar,” “Apr,” “May,” “Jun,” “Jul,” “Aug,” “Sep,” “Oct,” “Nov,” or “Dec”

DD

Day of the month: 1-31, ...

Get Palm OS Network Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.