in reply to IO::Socket reconnect

Check for
if ( $agent_socket->connected ){ print $agent_socket $monitoring_node . ".lmonitor." . $monitori +ng_name . ".rtt.value=" . $latency . "\n"; }else{ # Your retry logic here }

        "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin

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

    Hi NetWallah, I tried to do it before post the issue here, but unfortunately it doesn't work.

      Could you expand a little on what "it" was that you tried, and what you mean by "doesn't work" - What specific messages did you get ?

      Did it still try to send if the socket was not connected ?

      WHat was your recovery logic ?

              "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin

        Of course. I tried to use same code as in your example. such code don't work for me. As I understand if I open socket to accept connections (not to create to a remote host) then it doesn't have state "connected" at all. Not sure if my suggestion is right, I'm beginner in Perl (and in programming). I checked my suggestion with this example: http://www.perlmonks.org/?node_id=884065 Script's logic is to accept a connection and start to send a data, if connection was closed, then stop to publish a data and wait for a new connection