File: faimond

package info (click to toggle)
fai 3.1.8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,144 kB
  • ctags: 164
  • sloc: sh: 3,410; perl: 1,780; makefile: 113
file content (47 lines) | stat: -rwxr-xr-x 1,341 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w

# $Id: faimond 3022 2005-11-10 12:47:47Z lange $
#*********************************************************************
#
# faimond -- monitor daemon which collects client status info
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2003-2004 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************

use strict;
use Socket;

$| = 1;
my $port = 4711;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub server_init() {

  my $proto = getprotobyname('tcp');
  socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
  setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!";

  my $paddr = sockaddr_in($port, INADDR_ANY);

  bind(SERVER, $paddr) or die "bind: $!";
  listen(SERVER, SOMAXCONN) or die "listen: $!";
  print "FAI monitoring daemon started on port $port\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub big_loop() {

  # accept a connection, print message received and close
  my ($client_addr,$inp);
  while ($client_addr = accept(CLIENT, SERVER)) {
    $inp = <CLIENT>;
    close CLIENT;
    print "$inp";
  }
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

server_init;
big_loop;