Dear community, thank you all to partecipate, I would like to share my (very simply) solution to my question. The following code works perfect and suit my needs.

BTW, the concept behind solution is simple too:
-- Open a socket
-- Server is listining?
---- YES: OK Connect
---- NO: Enter in loop until Server will be ready
-- Send data
-- Is there any response from server?
---- YES: Continue sending loop
---- NO: (Empty Response): Call OpenSocket and wait untill Server will be ready again.
#!/usr/bin/perl use IO::Socket; my $sock1; sub OpenSocket{ while ( !$sock1 ) { $sock1 = IO::Socket::INET->new ( Proto => "tcp", PeerAddr => "192.168.10.7", PeerPort => "8000", Timeout => "1") } } ################ START SCRIPT ################# OpenSocket(); sleep(1); my $str="DATA TO SEND" while(1) { $sock1->send($str); sleep(1); $sock1->recv($channel1, 128); if ( !$channel1 ) { $sock1->shutdown(2); $sock1=""; print "DISCONNECTED... I'M RECONNECTING AND RESEND PREVIOUS PACKET +\n"; OpenSocket(); sleep(1); $sock1->send($str); } } close($sock1);

In reply to Re: Check connection state prior to send data by Lucas Rey
in thread Check connection state prior to send data by Lucas Rey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.