The following code is used for the SDD detector. It is a TCP/IP server that re-opens the socket after the client disconnected.
#!/usr/bin/perl -w # # SDD server # use IO::Socket; use Socket; my $text = " " x 100000; my $command = " " x 320; my $sock = IO::Socket::INET->new( Listen => 5, LocalPort => 9001, Reuse => 1, Proto => 'tcp'); reopen: print " accepting connections \n"; my $new_sock = $sock->accept(); while(1) { print " waiting for input \n"; if( ! $new_sock->recv( $command, 128)) { print " recv returned error \n"; goto reopen; } $command =~ s/^\s*(.*?)\s*$/$1/; print " received $command \n"; goto finish if( $command =~ /bye/i); if( $command =~ /^mcareadSR/i) { `$text >> temp.lis`; # Shell Kommando $text = `cat temp.lis`; # Shell Kommando } elsif( $command =~ /^mcareadCR/i) { `$text >> temp.lis`; $text = `cat temp.lis`; } elsif( $command =~ /^messen/i) { `mca123buenon >> temp.lis`; $text = `cat temp.lis`; } elsif( $command =~ /^halt/i) { `set buen off >> temp.lis`; $text = `cat temp.lis`; } elsif( $command =~ /^get_fec_spec$/i) { $text = `mca6_part 0 4095 2 2`; } elsif( $command =~ /^get_fec_spec(\d+)$/) { $text = `mca6_part 0 4095 $1 $1`; } elsif( $command =~ /^init_fec_mca/i) { `mca1`; `mca2`; `mca3`; $text = "executed init_fec_mca"; } print " sending $text\n EOF\n"; print " in replying $command \n"; $new_sock->send( "$text\nEOF\n"); } finish: $sock->close(); exit 0;