i"m in TrOuBlE

i"m in TrOuBlE

am 14.12.2004 18:55:51 von Larry

Dear Mr.X

I'm a perl newbie and I've used MacPerl5.6.1.r2 (MacOS9.1) to run
my perl scripts.
It goes without saying that MacPerl is my all time favorite application
on MacOS9!
Unfortunately,I've been in trouble lately...

below is the code I've been working on:

[code]
#!/perl
#
# Little web server...by Gaetano

use strict;
use warnings;
use IO::Socket;

my ($client,$request,$content);

my $socket = IO::Socket::INET->new(LocalPort => '81',Proto => 'tcp',
Type => SOCK_STREAM, Reuse => 1, Listen => 10) || die "$!\n";

$socket->listen;

while (1)
{
$client = $socket->accept;
if ($client)
{
$client->autoflush(1);
recv($client,$request,10000,0);
#....
syswrite $client, "HTTP/1.0 200 OK\n";
syswrite $client, "Content-type:
application/octet-stream\n";
syswrite $client, "Content-Disposition: attachment;
filename=file.zip\n";
syswrite $client, "\n";

open(BYNA," binmode(BYNA);
while( read(BYNA,$content,1024) )
{
syswrite $client, $content;
}
close(BYNA);

close $client;
}

}

END {
print "The script died, but no one know why!\n";
}
[code]

Now, the script works much fine so far! I mean, I type 127.0.0.1:81 (or
my ip:81) in my IE5 browser and the download begins...

Unfortunately, if I press "Cancel" or "Stop" (during the download for
instance) at the browser side the script dies! ...or I should say: the
script exits without any errors! (And I gotta run it again...you don't
know how boring it is!!)

At first I was told this at "comp.lang.perl.misc":

"Your script may be responding to a signal like SIGPIPE. You need to
trap it and deal with it as appropriate. See %SIG in the perlvar
manpage."

some said:

"It's a MacPerl bug..."

I have no choise but to ask for your help!

hoping to hearing from you,

Gaetano from Roma




..
..
PS: I can't afford to turn on MacOSX, I don't have that kind of spending
money...