Instead of using a webserver, have your Perl script fork off its own server (if one isn't running at the time). It can communicate on a socket. We have a CGI program that keeps an large XSLT in standby. Using IO::Socket:
my $sock = new IO::Socket::INET ( LocalHost => $server,
LocalPort => 9200,
Proto => 'tcp',
Listen => 2,
ReuseAddr => 1,
);
die "socket creation error: $!" unless $sock;
while( my $client = $sock->accept() ) {
binmode $client, ":utf8";
$client->autoflush(1);
# Read data
while( $client->recv( $in_buffer, $buffer_size ) ) {
# Store data
}
# Process data
# Return data
$client->send( $output );
}
Some things to consider to make it dummy proof is allow it to adjust what port is runs on at runtime, and to have the server exit after a while to avoid zombie processes.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.