#! /usr/bin/perl

# This is no real example, it is just for testing the
# server. And the server is just for testing the Quancom.pm.
# So - it's almost of no use for you :)
#
# should be called in blib environment:
# perl -Mblib examples/test-server ...

use strict;
use warnings;
use POSIX qw(tmpnam);
use Getopt::Long;
use Pod::Usage;
use Quancom::Test::Server;

$SIG{INT} = sub { warn "got INT, exit now\n"; exit 0; };

GetOptions(
    "help" => sub { pod2usage(-verbose => 0, exit => 0) },
    "man"  => sub { pod2usage(-verbose => 2, exit => 0) },
) or pod2usage;

my $server = new Quancom::Test::Server @ARGV ? $ARGV[0] : tmpnam();
$server->run;

__END__

=head1 NAME

test-server

=head1 SYNOPSIS

    test-server [socket|[address:]port|-]

=head1 DESCRIPTION

This command starts a test server simulating a Quancom USB-OPTO device.
It's use is for testing purpose only (testing the Quancom.pm module).

=head1 INVOCATION

On invocation you may pass a parameter:

=over

=item I<socket>

This should be the name of a socket file. The socket file must not
exist, it will be created. The name has contain at least on slash ("/")
to be distinguished from a port number.

=item [I<address:>]I<port>

Using this the server will bind to the specified port on 0.0.0.0 or the 
address supplied.

=item B<->

Using a single "-" the server will communicate over STDIN/STDOUT. Some
changes in behaviour are implicit set. See L<Quancom::Test::Server> for
more details. This option is for testing the test server.

=item B<no parameter at all>

If you do not pass anything, the server creates a temporary socket file.

=back

In all cases, the server tells you on STDERR about the "channel" used
for communication.

=cut
