Source

ruptime / ruptime.pl

#!/usr/bin/perl

# Demonstration client for obtaining uptime from Daybo Logic ruptimed
# servers.  Type ruptime [hostname]
# Written 20051230 by David Duncan Ross Palmer

use IO::Socket;
use strict;

my($sock, $server_host, $msg, $port, $ipaddr, $hishost, 
   $MAXLEN, $PORTNO, $TIMEOUT);

$MAXLEN  = 1024;
$PORTNO  = 30669;

$server_host = shift; # From command line

$sock = IO::Socket::INET->new(
  Proto => 'tcp',
  PeerPort  => $PORTNO,
  PeerAddr  => $server_host
) or die "Creating socket: $!\n";

$sock->recv($msg, $MAXLEN);
($port, $ipaddr) = sockaddr_in($sock->peername);
$sock->close();
# $hishost = gethostbyaddr($ipaddr, AF_INET);
print "$msg\n";