Create a TCP/IP Connection

perl ./server_code.pl

If it becomes more elaborate, you will need to create some scaffolding to run it from the command line, but it usually pays itself back pretty quickly.

Once it's in production use, if it throws any errors, they will be visible in Apache's error log (if you are lucky).

Oh, this is what you meant. I tried this and this works. The simple server code works. The problem is invoking the server code from the client code. That seems to be the point where it is failing.

So do you get anything in Apache's logs?

where on the web server do I actually find these logs?

Regards,
Garric

The configuration depends a lot on how you installed Apache. On Linux you would commonly find the logs in /var/log/apache but there are many variations; many sites want one log per domain name, each in the domain owner's home directory, so that's a common configuration also. Look in httpd.conf for the logging configuration.

I looked into error_log but found nothing. I am not sure if this client code is fine

#!/usr/bin/perl

use IO::Socket;

if (@ARGV < 1) { print "usage: perl send_to_server.pl [host]\n"; exit; }
$host = $ARGV[0];

$var = IO::Socket::INET->new( PeerAddr=>"$host",
                              PeerPort=>"80",
                              Proto=>"tcp") || die " $! Connection failed.";

print $var "GET cgi-bin/server_code.pl?data=abc HTTP/1.0\r\n\r\n";

and then i run it like this
#>./clientCode.pl <web server>

How can I be sure if the server code is running when called here.

First, test that the client connects correctly. Run netcat on a random port on the server and change the client to connect to that port (let's say 4343 again for old times' sake).

For debugging, you might want to change the client code to die with a diagnostic if print fails, and also add a close and die if that fails.

On the server, make a debugging version of the CGI which prints something useful to standard output as well (which will be served up back to the connecting client), so you can see that it runs. Connect to it with your browser and check that you get the results you expect.

the simple example works fine .. like this

Client

#!/usr/bin/perl

use IO::Socket;
if (@ARGV < 1) { print "usage: perl send_to_server.pl [host]\n"; exit; }
$host = $ARGV[0];

$var = IO::Socket::INET->new( PeerAddr=>"$host",
                              PeerPort=>"4343",
                              Proto=>"tcp") || die " $! Connection failed.";

print $var "\n Wazza \n";
#print $var "GET /cgi-bin/server_code.pl?data=abc HTTP/1.0\r\n\r\n";

#> ./clientCode.pl <web_server>

Server

> netcat -l -p 4343

Wazza

So, can you check again if its with the line that we are printing into port 80?

I'm sorry, I don't understand the question. You have Apache up and running? You have some basic demo CGI up and running? There are a few which ship with Apache. Or pull something from one of those "become a CGI guru in 21 minutes" web sites.

Hi era,

What I was trying to say there was this - The example example u told me to try is what I have tried there. I ran netcat -l -p 4343 on my web server. Then in the client code, I try to print into the same - 4343 - port on the web server. This works just fine.

But when I try calling the serverside scipt residing in cgi-bin from the client, through port 80, it doesnt seem to work. That's what I am trying to say.

But you have Apache up and running, and see hits in the logs when you connect?