Have you checked the return error message from Net::Telnet? You can check the error message with the following code:

printf "%s\n", $telnet->errmsg();
Which version of Net::Telnet are you using? The version I am using is 3.03. The following is an extract from the module -

## Connect to server, timing out if it takes too long. eval { ## Turn on timer. local $SIG{"__DIE__"} = "DEFAULT"; local $SIG{ALRM} = sub { die "timed-out\n" }; alarm $timeout; ## Lookup server's IP address. $ip_addr = inet_aton $host or die "unknown remote host: $host\n"; ## Create a socket and attach the filehandle to it. socket $self, AF_INET, SOCK_STREAM, 0 or die "problem creating socket: $!\n"; ## Open connection to server. connect $self, sockaddr_in($port, $ip_addr) or die "problem connecting to \"$host\", port $port: $!\n"; }; alarm 0;
The module code will try to resolve the host IP before making a connection with inet_aton, create socket, and connect to the specified server.

Now that explains why the call to open does not wait for 10 seconds on invalid addressed, because as soon as the host resolution fails, the evalutation block will terminate (with alarm trigger reset) at the line die "unknown remote host: $host\n";.

I suspect this is the cause for your problem. Check the $telnet->errmsg() nevertheless to see what's the reason for the failure.


In reply to Re: Net::Telnet timeout fails by Roger
in thread Net::Telnet timeout fails by JykkeDaMan

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.