Appreciate the response.
I looked at CGI.pm and the documentation regarding it. But all the examples I could find using CGI.pm were the case where there was just the need to process one POST/GET request..
In my case I've created a server that needs to process many POST/GET requests. What I am missing is the following loop....
use cgi
while (a request to localhost:6789 server)
{
process the request with CGI.pm modules
}
here's the code that makes an attempt at this loop....
use IO::Socket;
use Net::hostent;
use CGI;
# Constants
$cnst_port = 6789; # Port we want to listen to
$cnst_server = 'http://localhost:' . $cnst_port . '/'; # Server addre
+ss
$server = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $cnst_po
+rt, Listen => SOMAXCONN, Reuse => 1 );
die "Can\'t set up server" unless $server;
print STDERR "Server Version 0.637\n" .
"Server accepting clients via $cnst_server\n";
while ($client = $server->accept())
{
$client->autoflush(1);
$cgi = new CGI;
$request_path_translated = $cgi->path_translated();
$request_query_string = $cgi->query_string();
$request_request_method = $cgi->request_method();
print STDERR "request_path_translated = $request_path_translated\n";
print STDERR "request_query_string = $request_query_string\n";
print STDERR "request_request_method = $request_request_method\n";
RETURN_DUMMY_PAGE ();
close($client);
}
sub RETURN_DUMMY_PAGE
{
print $client
'HTTP/1.0 200 OK' . "\n" .
'Content-type: text/html' . "\n\n" .
'<HTML>' . "\n" .
' <HEAD><TITLE>Asayo - LED Sign Software XL</TITLE></HEAD>' . "\n"
+ .
' <BODY><H1>Dummy Page</H1></BODY>' . "\n" .
'</HTML>' . "\n";
}
The dummy page gets returned each time, but the CGI calls return nothing..
Any ideas? |