Hi Rodrigo
Thanks for your reply.
Yes, in fact on my XP laptop I always get 20 seconds connection timeout
no matter what I set the module timeout to; so this is the same problem
you have but as 20secs is not far off the 10secs timeout I normally use,
I never noticed it before.
However on on a Solaris machine the module behaves correctly (also on
Cygwin perl as you state) and whatever timeout is defined in the module
this also applies to the connection timeout.
Had to do some digging; my module relies on Net::Telnet for Telnet
access, which in turn relies on IO:Socket:INET. So all I'm doing is
passing on the timeout setting to Net::Telnet.
Turns out that IO::Socket::INET has no connection timeout handling
(well, the code is there but commented out; go figure..!; see
http://stackoverflow.com/questions/3570440/perl-how-to-get-iosocketinet-timeout-after-x-seconds
).
The author of Net::Telnet must have been well aware of this, as his
module, as a workaround, wraps the Socket connection call in an eval
block and sets an alarm to the configured timeout. Now this eval/alarm
code works fine on any unix system, but simply does not work on Win32
Activestate distribution (I'm using v5.12.3).
Infact the problem is to be found in ActiveSate's release notes where it
clearly states that signals are unsupported by the Win32 API and the
alarm() function is not implemented. The more general problem is that
"Windows does not have signals. POSIX systems like Linux have signals";
so for example Strawberry Perl for Win32 will have exactly the same
problem as ActiveState.
So, I'm afraid I don't see how I can plaster over all these underlying
deficiencies; I guess one could open the connection in a thread and then
kill the thread if the connection is not established within the timeout
period; but I'm not comfortable introducing thread dependency in my
module as this would likely limit it's use under older Perl
distributions. However this is one option you could investigate in your
own code.
Now, in your case, you said you were getting 3 minute timeouts (slightly
worse than my 20 secs!); so I had a look at that. Given that, as
described above, no Perl connection timeout is enforced under Win32, it
must follow that the Windows API timeouts are in force. From a bit more
digging:
http://technet.microsoft.com/en-us/library/cc739819(WS.10).aspx
HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services: \Tcpip \Parameters
TcpInitialRTT: Defines what the initial time-out settings are for new
connections. This number in seconds is doubled each time it retransmits
before timing a connection out. Defaults to 3.
TcpMaxConnectRetransmissions: Defines the number of retransmissions
before timing a connection out. Defaults to 2.
On my XP laptop, neither of the above Keys is set in my Registry; so I
get the following default timeout: 3+6+12=21 secs.
I guess on your machine you might have the above keys set to something else.
Hope this helps
Best regards
Ludovico Stevens
On Thu Oct 18 05:33:54 2012, rodrigo.olmos@gmail.com wrote:
Show quoted text> Sorry, the correct version in my system is 3.03.
> It's Windows XP SP3. Now I've tried three different Perl installations on
> the same system:
> ActivePerl 5.8.9 --> 3 minutes
> ActivePerl 5.16.1 --> 3 minutes
> Cygwin Perl 5.14.2 --> works fine (times out after 10 seconds)
>
> The Net::Telnet and Control::CLI versions are the same in the three of
them.
Show quoted text>
> 2012/10/17 Ludovico Stevens via RT <bug-Control-CLI@rt.cpan.org>
>
> > <URL:
https://rt.cpan.org/Ticket/Display.html?id=80237 >
> >
> > Hi
> > Can you clarify the Net::Telnet version please ?
> > The latest verson I know of is 3.03.
> > Also, what OS are you using ? Windows or Unix ?
> > Thanks
> >
> > On Wed Oct 17 05:57:41 2012, rodrigo.olmos@gmail.com wrote:
> > > When i try to connect to a host and it's not reachable, it takes
about 3
Show quoted text> > > minutes until I get a timeout. I tried to change:
> > > new Control::CLI('TELNET');
> > > to:
> > > new Control::CLI(Use => 'TELNET' , Timeout => 10);
> > > But it takes the same time until I get the timeout
> > > I'm using Control::CLI 1.03 and Net::Telnet 5.002
> >
> >
> >
> >