NAME
DDC::Filter - DDC Query utilities: server filters (wrapper sockets)
SYNOPSIS
##========================================================================
## PRELIMINARIES
use
DDC::Client;
use
DDC::Filter;
##========================================================================
## Constructors etc
$filter
=
$CLASS_OR_OBJ
->new(
%args
);
##-- new filter object
##========================================================================
## Logging
$fh
=
$filter
->logfh();
##-- get log filehandle
$filter
=
$filter
->logclose();
##-- close log filehandle
undef
= logmsg(
$level
,
@message
);
##-- log a message
##========================================================================
## Server Methods: run
undef
=
$filter
->run();
##-- run the wrapper daemon
##========================================================================
## Server Methods: callback
\
&callback_sub
=
$filter
->_callback(
$netserver_generic
);
##-- top-level callback
##========================================================================
## Server Methods: filters
$filtered_data
=
$filter
->filterInput(
$data_from_client
);
##-- input filtering callback
$filtered_data
=
$filter
->filterOutput(
$data_from_server
);
##-- output filtering callback
##========================================================================
## Inherited Methods
# ... any DDC::Client method ...
DESCRIPTION
Globals
- Variable: @ISA
-
DDC::Filter inherits from DDC::Client.
- Variable: %LOGLEVELS
-
Hash mapping symbolic log levels to numeric values, exportable.
Constructors etc
- new
-
$filter
=
$CLASS_OR_OBJ
->new(
%args
);
- %args:
-
(
connect
=>\
%connectArgs
,
##-- passed to IO::Socket::INET->new(), ##-- client args
bind
=>\
%bindArgs
,
##-- args to NetServer::Generic->new()
logfile
=>
$filename
,
##-- for logging (defualt=&STDERR)
loglevel
=>
$level
,
##-- log level
)
- additional object structure:
-
(
server
=>
$server
,
##-- a NetServer::Generic object for listening
)
- default %connectArgs:
-
PeerAddr
=>
'localhost'
,
PeerPort
=>50000,
Proto
=>
'tcp'
,
Type
=>SOCK_STREAM,
Blocking
=>1,
(for connecting to the underlying DDC server).
- default %bindArgs:
-
#hostname=>'localhost',
port
=>$60000,
mode
=>
"forking"
,
allowed
=>[
'127.0.0.1'
],
listen
=>128,
timeout
=>60,
(for accepting incoming client connections).
Logging
- logfh
-
$fh
=
$filter
->logfh();
Get logging filehandle.
- logclose
-
$filter
=
$filter
->logclose();
Close log filehandle.
- logmsg
-
undef
= logmsg(
$level
,
@message
);
Potentially log a message at $level.
Server Methods: run
- run
-
undef
=
$filter
->run();
Run the server, accepting incoming connections and calling callback(s) for each incoming query.
Server Methods: callback
- _callback
-
\
&callback_sub
=
$filter
->_callback(
$netserver_generic
);
Generic NetServer::Generic callback, called for each client. The default implmentation calls the filterInput() and filterOutput() methods, which should be sufficient for many applications.
Server Methods: filters
- filterInput
-
$filtered_data
=
$filter
->filterInput(
$data_from_client
);
This method may be overridden in derived classes to perform filtering of data to be passed to the real DDC server.
The default implementation just returns $data_from_client unchanged.
- filterOutput
-
$filtered_data
=
$filter
->filterOutput(
$data_from_server
);
This method may be overridden in derived classes to perform filtering of data to be passed back to the querying client.
The default implementation just returns $data_from_server unchanged.
AUTHOR
Bryan Jurish <moocow@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2006-2016 by Bryan Jurish
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.