Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: IO::Socket reconnect

by golux (Chaplain)
on Feb 14, 2016 at 02:57 UTC ( [id://1155189]=note: print w/replies, xml ) Need Help??


in reply to IO::Socket reconnect

Hi nikita.af,

Try catching the SIGPIPE signal. Something like:

my $b_err = 0; $SIG{'PIPE'} = sub { $b_err = 1 }; print $agent_socket $monitoring_node . ".lmonitor." . $monitoring_ +name . ".rtt.value=" . $latency . "\n"; if ($b_err) { # .... Handle the SIGPIPE error }

will likely work. If a SIGPIPE error happens while printing to the socket, the flag "$b_err" gets set, and you can then handle the error appropriately.

Oh, one other note -- isn't:

print $agent_socket "$monitoring_node.lmonitor.$monitoring_name.rtt.v +alue=. $latency .\n";

a lot easier to read than the original? ;-)

say  substr+lc crypt(qw $i3 SI$),4,5

Replies are listed 'Best First'.
Re^2: IO::Socket reconnect
by nikita.af (Acolyte) on Feb 15, 2016 at 01:17 UTC

    Hi golux, thank you, it seems to be the way I need. Also thanks for the remark, I'll correct it)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found