#! perl -slw
use strict;
use Time::HiRes qw[ time ];
binmode STDIN;
my $buf = '';
while( 1 ) {
sysread( STDIN, $buf, 1 );
my $end = time() + 7;
sleep 0.1 while time() < $end;
sysread( STDIN, $buf, 1024, length( $buf ) );
printf "Got: '%f'\n", unpack 'd', $buf;
}
####
#! perl -sw
use strict;
use Time::HiRes qw[ time ];
binmode STDOUT;
while( 1 ) {
my $packet = pack 'd', time;
syswrite( STDOUT, $packet );
sleep 30;
}
####
C:\test>sender | listener
Got: '1423634772.508475'
Got: '1423634802.506555'
Got: '1423634832.504635'
Terminating on signal SIGINT(2)
Terminating on signal SIGINT(2)