NAME
Net::ClientServer - Implement a basic client/server architecture using a single platform
VERSION
version 0.0005
SYNOPSIS
The minimum configuration (specify a port):
my $platform = Net::ClientServer->new( port => 8020 );
$platform->server_socket;
...
if ( $platform->started ) { # Will attempt to connect to the listening socket
$platform->client_socket;
}
Save server state to disk:
$platform = Net::ClientServer->new( port => 8020, name => 'net-client-server' );
# Server pid will be stored in $HOME/.net-client-server/pid
# On daemonization, stderr will be outputted to $HOME/.net-client-server/stderr
With a basic startup & serve/accept routine:
my $port = 8020;
$platform = Net::ClientServer->new(
port => $port,
start => sub {
print STDERR "Server listening on $port\n";
},
serve => sub {
my $client = shift; # The client socket
$client->print( "Hello, World.\n" );
},
);
$platform->start;
DESCRIPTION
Met::ClientServer is a tool for implementing a basic client/server architecture using a single platform. It is easily configured for daemonizing and maintaining state on disk (pidfile & stderr).
The minimum configuration is very simple, requiring only a port number:
my $platform = Net::ClientServer->new( port => 8020 );
$platform->server_socket;
...
$platform->client_socket;
USAGE
The API is still young and pretty fluid. See the SYNOPSIS for examples (for now)
Daemonization (via ->start
) is on by default, disable it with: daemon => 0
SEE ALSO
AUTHOR
Robert Krimen <robertkrimen@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.