ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/ihost-perl/host.pl
Revision: 1.2
Committed: Wed Feb 28 15:51:17 2001 UTC (23 years, 6 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
We no longer require this file, it was just a mess around to see if things
worked :) ihost.pl superceeds these.

File Contents

# Content
1 #!/usr/bin/perl -w
2
3 # perl host program, pjm2@ukc.ac.uk
4 # this is not a full host.
5 # development was halted as perl is unable
6 # to send udp packets from raptor.
7
8 use strict;
9 use Socket;
10 use Sys::Hostname;
11
12 $| = 1;
13
14 my ($them) = $ARGV[0];
15 my ($port) = $ARGV[1];
16
17 $them = 'localhost' unless $them;
18 $port = 4589 unless $port;
19
20 my($AF_INET) = 2;
21 my ($SOCK_DGRAM) = 2;
22
23 my($hostname);
24 chop($hostname = `hostname`);
25
26 my($name, $aliases, $proto, $type, $len, $thisaddr, $thataddr);
27 ($name, $aliases, $proto) = getprotobyname('udp');
28 ($name, $aliases, $port) = getservbyname($port, 'udp') unless $port =~ /^\d+$/;
29 ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
30 ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
31
32 my($sockaddr) = 'S n a4 x8';
33
34 my $this = pack($sockaddr, $AF_INET, 0, $thisaddr);
35 my $that = pack($sockaddr, $AF_INET, $port, $thataddr);
36
37 if (socket(S, $AF_INET, $SOCK_DGRAM, $proto)) {
38 print "Socket okay!\n";
39 }
40 else {
41 die $!;
42 }
43
44 if (bind(S, $this)) {
45 print "Bind okay!\n";
46 }
47 else {
48 die $!;
49 }
50
51 printf "%-12s %8s %s\n", "localhost", 0, scalar localtime time;
52
53 exit 0;