in reply to Socket programming & CGI hell

Your process() function executes one command and then returns. As far as I can tell, it doesn't even close the socket (unless there was an error). You need to do something like:
sub process {
    while(@_) {
        my $line = shift @_;
        .
        .
        .
    }

    print $new_sock, "Done.\n";
    shutdown $newsock, 0;
}

That way it will execute every command that you give it and then close the socket properly. Also, any "returns" in your process() function should be changed to "nexts".

lhoward also makes a good point about security.

 

Replies are listed 'Best First'.
RE: Re: Socket programming & CGI hell
by TQuid (Sexton) on Jul 19, 2000 at 22:58 UTC
    Execute one command and return is exactly what process() is supposed to do; sorry if that is not clear. It's not meant to close the socket until it receives a BYE command. What should happen (and what does happen, if you telnet in) is that it processes one line, returns, processes the next, and so on, until it gets a BYE, and then it disconnects, and Bob's your uncle.

    Your solution would work nicely for batch processing, but that isn't what I want to do.

    --TQuid