Daytime Protocol

Daytime is an almost extinct protocol that can be used to get the current time from a server. It is defined by RFC867. It can be used over TCP or UDP.

TCP Connections

The server should listen on TCP port 13. When it accepts a new connection, it should send the current time in an UNSPECIFIED format, discard any received data and close the connection.

UDP Connections

The server should listen for UDP datagrams on port 13. When it receives a datagram, it should send a reply containing the current time in an UNSPECIFIED format. Any data it receives in the datagram should be discarded.

Time format

The time format is not specified in the RFC, but it is recommended to be limited to ASCII characters, space, carriage return (\r) and line feed (\n).

Example server in Python

import socket
import time

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("", 13)) # Bind to port 13

while True:
    sock, addr = server.accept()
    daytime = time.strftime("%A, %B %d, %Y, %H:%M:%S\n") # Tuesday, February 22, 1982 17:37:43

Comments BETA

Page built on Sun Apr 7 22:36:39 BST 2019