in reply to program dies when printing to closed socket, I think
One first thing to note is that the <IN> in print $client <IN>; is executing in list context, which means you'll only ever call the $client->connected once, before you're sending the entire content to the client...
Writing the content line-wise might improve the situation somewhat
while ( my $line = <IN> ) { if ( $client->connected ) { print $client $line; } }
however, this is of course not yet a real satisfactory solution to your problem of the client (potentially) disconnecting before you can complete writing the line.
Update: BTW, some time ago, I was having a somewhat related problem (involving a pipe, not a socket, though...), in which I learned that such things can be trickier than I first thought... ;) Maybe that discussion is of interest here, too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: program dies when printing to closed socket, I think
by HansB (Initiate) on Aug 16, 2007 at 16:15 UTC |