in reply to Socket programming & CGI hell
while ( $line = <$sock> ) { push @output, $line; } print $sock "BYE\n";
Your server doesn't close the connection until it gets a "BYE" from the client, but the client doesn't send a "BYE" until the server closes the connection. An easy solution would be to add a numeric or some other response from the server that marks the end of a command's output:
# In the server script sub process { ... print $new_sock <<EOF; OK $output 123 End of output EOF } # In the CGI script sub execute { while ( ($line = <$sock>) !~ /^123/ ) { push @output, $line; } print $sock "BYE\n"; }
-Matt
|
|---|