I can't seem to find a public daytime server
A Google search for public daytime server rapidly finds the National Institute of Standards and Technology, which runs NTP and DAYTIME servers.

See Set Your Computer Clock Via the Internet and NIST Internet Time Servers.

Your next challenge is to write a DAYTIME server, and configure launchd on your own system to run it on demand.

The following modification of your code will parse the NIST standard DAYTIME format.

use strict; use warnings; #use 5.010; use IO::Socket; #my $host = 'localhost'; #my $host = 'time.nist.gov'; #my $host = 'nist1-sj.ustiming.org'; my $host = 'time-nw.nist.gov'; # pester microsoft my $port = 'daytime(13)'; my $sock = IO::Socket::INET->new( Proto => 'tcp', PeerHost => $host, PeerPort => $port, ) or die "cannot connect: $!"; while (<$sock>) { s/^[[:space:]]+//; s/[[:space:]]+\z//s; next if /^$/; # NIST Daytime Protocol format # http://tf.nist.gov/service/its.htm # JJJJJ YR-MO-DA HH:MM:SS TT L H msADV UTC(NIST) OTM if ($_ =~ /^(\d+)\s+(\d{2})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{ +2})\s+(\d{2})\s+(\d)\s+(\d)\s+([0-9\.]+)\s+UTC\(NIST\)\s+(.)/) { my ($mjd, $yr, $mo, $da) = ($1,$2,$3,$4); my ($hour, $min, $sec, $dst, $lsec) = ($5,$6,$7,$8,$9); my ($health, $msADV, $otm) = ($10,$11,$12); print "NIST: $yr-$mo-$da $hour:$min:$sec\n"; } else { print "$_\n"; } }

In reply to Re: sockets: problems with daytime client by gmargo
in thread sockets: problems with daytime client by 7stud

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.