~morty/fai/trunk

« back to all changes in this revision

Viewing changes to bin/faimond

  • Committer: Thomas Lange
  • Date: 2005-11-10 12:47:47 UTC
  • Revision ID: git-v1:cf3cbb08a817ca4214ba8686e237d2ea61fdf30d
rename directory scripts to bin, fix pathes in Makefile

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
# $Id$
 
4
#*********************************************************************
 
5
#
 
6
# faimond -- monitor daemon which collects client status info
 
7
#
 
8
# This script is part of FAI (Fully Automatic Installation)
 
9
# (c) 2003-2004 by Thomas Lange, lange@informatik.uni-koeln.de
 
10
# Universitaet zu Koeln
 
11
#
 
12
#*********************************************************************
 
13
 
 
14
use strict;
 
15
use Socket;
 
16
 
 
17
$| = 1;
 
18
my $port = 4711;
 
19
 
 
20
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
21
sub server_init() {
 
22
 
 
23
  my $proto = getprotobyname('tcp');
 
24
  socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
 
25
  setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!";
 
26
 
 
27
  my $paddr = sockaddr_in($port, INADDR_ANY);
 
28
 
 
29
  bind(SERVER, $paddr) or die "bind: $!";
 
30
  listen(SERVER, SOMAXCONN) or die "listen: $!";
 
31
  print "FAI monitoring daemon started on port $port\n";
 
32
}
 
33
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
34
sub big_loop() {
 
35
 
 
36
  # accept a connection, print message received and close
 
37
  my ($client_addr,$inp);
 
38
  while ($client_addr = accept(CLIENT, SERVER)) {
 
39
    $inp = <CLIENT>;
 
40
    close CLIENT;
 
41
    print "$inp";
 
42
  }
 
43
}
 
44
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
45
 
 
46
server_init;
 
47
big_loop;