[ale] Apache and CGI echo server
Christopher Fowler
cfowler at outpostsentinel.com
Sun Nov 26 10:15:58 EST 2006
I'm trying to write a simple echo server test program to run as a CGI in
apache.
use IO::Select;
use strict;
my $pid = fork();
exit 0 if $pid;
open LOG, ">> /tmp/echo.log";
$| = 1;
print "Test Echo Server.\n";
my $fdset = new IO::Select;
my $wfdset = new IO::Select;
my $r_ready;
my $w_ready;
my $error;
my $timeout = 30;
my $err;
$fdset->add(\*STDIN);
while (1) {
SELECT:
my ($r_ready, $w_ready, $error) =
IO::Select->select($fdset, $wfdset, $err, $timeout);
# If nothing has occured, we have timedout
if($r_ready eq "") {
goto SELECT;
}
foreach my $ready (@$r_ready) {
my $data;
if($ready == \*STDIN) {
sysread($ready, $data, 1);
syswrite(1, $data, 1);
}
}
}
The problem that I'm having is that when I do the following:
[tomcat at sam-devel SystemConfig]$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /SC/echo.pl
Echo this line
The program does not seem to echo back what I sent. I tested the
program on the command line so I know it works. I tested the concept on
an embedded device running thttpd and that works. I think maybe Apache
is doing its own buffering. The idea is that I want a Java Applet which
is a real-time client to our software to communicate via the same port
as the apache is on. This is so I can avoid firewall issues at customer
sites. I originally got this idea when using KVM over IP equipment.
They use a web server for a normal HTML interface and their real-time
desktop client uses the same port (80 or 443) to allow users to
interface with the PCs that are connected to the KVM. Maybe someone
here that is familiar with apache can tell me what apache may be doing
and how I could turn it off.
Thanks,
Chris
More information about the Ale
mailing list