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.
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.
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.
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 (
Example server in Python
import socket import time server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(("0.0.0.0", 13)) # Bind to port 13 server.listen(5) while True: sock, addr = server.accept() daytime = time.strftime("%A, %B %d, %Y, %H:%M:%S\n") # Tuesday, February 22, 1982 17:37:43 sock.send(daytime.encode("ascii")) sock.close()