RTIME(3)

πŸ’– RTIME(3) β€” Library Functions Manual πŸ’–

okay bestie, gather round, we're talking about rtime from the RTIME(3) manual, and it's giving "old-school internet magic" ✨


🌸 NAME 🌸

rtime β€” get remote time πŸ•°οΈβœ¨


πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>

int
rtime(struct sockaddr_in *addrp, struct timeval *timep,
    struct timeval *timeout);

πŸ’… DESCRIPTION πŸ’…

so basically, the rtime() function goes and consults the Internet Time Server at the address that addrp points to, and then it hands you back the remote time in the timeval struct that timep points to. no cap, that's the whole vibe πŸ’–

normally? it uses the UDP protocol when it's consulting the Time Server. periodt.

the timeout argument is the "how long are we waiting before we give up on a reply" girlie β€” it says how long the routine should wait before giving up when waiting for a reply. ⏳

but if timeout is specified as NULL? plot twist 🫒 β€” the routine switches to TCP instead, and it will block until a reply is received from the time server. like, full commitment, no leaving, it's waiting right there. main character energy fr fr 😭


πŸ”₯ RETURN VALUES πŸ”₯

  • returns the value 0 if successful πŸ₯³
  • otherwise the value -1 is returned, and the global variable errno is set to indicate the error πŸ’€
bestie if you see a -1, go check errno immediately, that's where the tea is 🍡

✨ AVAILABILITY ✨

the rtime() function is part of libtirpc. πŸ’œ


and that's the whole page, bestie πŸ¦‹ this little slice of Debian history is dated November 22, 1987, and it's from the Library Functions Manual β€” RTIME(3), no cap πŸ’…βœ¨

πŸ“¦ where this page comes from