examples/test-server
changeset 14 7ccc679ac5db
parent 13 d6f681329542
child 15 2d41fac09084
equal deleted inserted replaced
13:d6f681329542 14:7ccc679ac5db
     6 
     6 
     7 use strict;
     7 use strict;
     8 use warnings;
     8 use warnings;
     9 use POSIX qw(tmpnam);
     9 use POSIX qw(tmpnam);
    10 use Getopt::Long;
    10 use Getopt::Long;
       
    11 use Pod::Usage;
    11 use Quancom::Test::Server;
    12 use Quancom::Test::Server;
    12 
    13 
    13 $SIG{INT} = sub { warn "got INT, exit now\n"; exit 0; };
    14 $SIG{INT} = sub { warn "got INT, exit now\n"; exit 0; };
    14 
    15 
       
    16 GetOptions(
       
    17     "help" => sub { pod2usage(-verbose => 0, exit => 0) },
       
    18     "man"  => sub { pod2usage(-verbose => 2, exit => 0) },
       
    19 ) or pod2usage;
       
    20 
    15 my $server = new Quancom::Test::Server @ARGV ? $ARGV[0] : tmpnam();
    21 my $server = new Quancom::Test::Server @ARGV ? $ARGV[0] : tmpnam();
    16 $server->run;
    22 $server->run;
       
    23 
       
    24 __END__
       
    25 
       
    26 =head1 NAME
       
    27 
       
    28 test-server
       
    29 
       
    30 =head1 SYNOPSIS
       
    31 
       
    32     test-server [socket|[address:]port|-]
       
    33 
       
    34 =head1 DESCRIPTION
       
    35 
       
    36 This command starts a test server simulating a Quancom USB-OPTO device.
       
    37 It's use is for testing purpose only (testing the Quancom.pm module).
       
    38 
       
    39 =head1 INVOCATION
       
    40 
       
    41 On invocation you may pass a parameter:
       
    42 
       
    43 =over
       
    44 
       
    45 =item I<socket>
       
    46 
       
    47 This should be the name of a socket file. The socket file must not
       
    48 exist, it will be created. The name has contain at least on slash ("/")
       
    49 to be distinguished from a port number.
       
    50 
       
    51 =item [I<address:>]I<port>
       
    52 
       
    53 Using this the server will bind to the specified port on 0.0.0.0 or the 
       
    54 address supplied.
       
    55 
       
    56 =item B<->
       
    57 
       
    58 Using a single "-" the server will communicate over STDIN/STDOUT. Some
       
    59 changes in behaviour are implicit set. See L<Quancom::Test::Server> for
       
    60 more details. This option is for testing the test server.
       
    61 
       
    62 =item B<no parameter at all>
       
    63 
       
    64 If you do not pass anything, the server creates a temporary socket file.
       
    65 
       
    66 =back
       
    67 
       
    68 In all cases, the server tells you on STDERR about the "channel" used
       
    69 for communication.
       
    70 
       
    71 =cut