Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How does one trap a Broken Pipe (Moved from Q&A)

by Russ (Deacon)
on Dec 07, 2000 at 21:51 UTC ( [id://45551]=perlquestion: print w/replies, xml ) Need Help??

Russ has asked for the wisdom of the Perl Monks concerning the following question:

This post was moved from Categorized Questions and Answers.
Please do not vote for this node. It will affect the wrong user.
Thank You -- Q&AEditors

How do you trap a broken pipe error? For instance the following function reads until an \n is found, however if the client in this case is a browser, and it does not send the \n, but instead hits the stop button , the server dies with Broken Pipe error.

Anyone know how to properly trap a broken pipe error?

eval { if( !( print_errs( $got = Net::SSLeay::ssl_read_all($ssl)))){ if ( $got ne ''){ Net::SSLeay::ssl_write_all($ssl, $got) or die "$$: ssl write fai +led"; print "$got\n"; } } } || print "ERRORZ\n"; #I never get here due to an untrapable broken p +ipe error

Replies are listed 'Best First'.
(jeffa) Re: How does one trap a Broken Pipe (Moved from Q&A)
by jeffa (Bishop) on Dec 07, 2000 at 21:56 UTC
    This works for my current project:
    $SIG{PIPE} = sub { $error = "Lost connection - broken pipe." }; # your eval wrapped code here (YMMV) return $error if ($error);
    I owe credit to mdillon for this one via chatterbox, or was it tye . . .

    Jeff

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://45551]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-18 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found