XAS::Lib::Net::Server - A basic network server for the XAS Environment
my $server = XAS::Lib::Net::Server->new( -port => 9505, -host => 'localhost', -filter => POE::Filter::Line->new(), -alias => 'server', -inactivity_timer => 600, -eol => "\015\012" }
This module implements a simple text orientated network protocol. Data is sent out as delimited strings. Which means every string has a consistent EOL. These strings may be formatted, such as JSON. This module inherits from XAS::Lib::POE::Session.
This initializes the module and starts listening for requests. There are five parameters that can be passed. They are the following:
The name of the POE session.
The IP port to listen on.
The address to bind too.
Sets an inactivity timer on clients. When it is surpassed, the method reaper() is called with the POE wheel id. What reaper() does is application specific. The default is 600 seconds.
An optional filter to use, defaults to POE::Filter::Line
An optional EOL, defaults to "\015\012";
Turns on TCP keepalive for each connection.
Called when the inactivity timer is triggered.
The POE wheel that triggered the timer.
This method will process the input from the client. It takes the following parameters:
The input received from the socket.
A hash variable to maintain context. This will be initialized with a "wheel" field. Others fields may be added as needed.
This method will process the output for the client. It takes the following parameters:
The output to be sent to the socket.
A hash variable to maintain context. This uses the "wheel" field to direct output to the correct socket. Others fields may have been added as needed.
This method will process the error output from the client. It takes the following parameters:
This method is called after the client connects. This is for additional post connection processing as needed. It takes the following parameters:
The id of the clients wheel.
This returns the current port for that wheel.
The POE wheel to use.
This returns the current host name for that wheel.
This returns the current client for that wheel.
Kevin L. Esteb, <kevin@kesteb.us>
Copyright (c) 2012-2015 Kevin L. Esteb
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.
To install XAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XAS
CPAN shell
perl -MCPAN -e shell install XAS
For more information on module installation, please visit the detailed CPAN module installation guide.