can't locate method new IO::Socket::INET

T

ten8ciousb

Sometimes, not always, an attempt to create a new socket connection
fails with this message:
Socket::INET" (perhaps you forgot to load "IO::Socket::INET"?) at
/usr/local/lib/perl5/5.6.1/IO/Socket/INET.pm line 32

Any ideas why or how INET.pm fails saying it can't find new in INET.pm?
The script runs on many servers many times a day, but only fails on one
and generally about the same time of the day. Okay. Seems kind of
obvious that is something specific to the server and the time of day.
But, within the same script there are multiple calls to create sockets
to different servers and they complete successfully.

I'm kind of out of my element on the internals of perl here, but my
thoughts:
Is it trying to find IO::Socket::INET.pm in @INC in order to identify
the super class, which is IO::Socket?
Does that mean that @INC has somehow become 'corrupted' during runtime?

any other thoughts.
Or has perl's symbol table become corrupted so it doesn't know what
"new" is?


nothing fancy in the script:

use IO::Socket;
use IO::Socket::INET;

$sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
);

for reference : in INET.pm:
@ISA = qw(IO::Socket);
....
sub new {
my $class = shift;
unshift(@_, "PeerAddr") if @_ == 1;
return $class->SUPER::new(@_); ### Here's line 32

}
 
S

Sisyphus

..
..
use IO::Socket;
use IO::Socket::INET;

$sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
);

Pretty much stumped by this. (The *full* error message as a copy'n'paste
could be helpful as that would remove *all* guesswork on our part.)

Normally you don't 'use IO::Socket::INET;' - you just 'use IO::Socket;'. I
can't think of why that would stuff things up, but it's a change you could
try.

Cheers,
Rob
 
T

ten8ciousb

Sisyphus said:
.
.

Pretty much stumped by this. (The *full* error message as a copy'n'paste
could be helpful as that would remove *all* guesswork on our part.)

Normally you don't 'use IO::Socket::INET;' - you just 'use IO::Socket;'. I
can't think of why that would stuff things up, but it's a change you could
try.

Cheers,
Rob


Thanks for the reply.
It originally just had use IO::Socket, I added the use
IO::Socket::INET, just to make sure it was loaded.
I've added a die handler that prints a stack trace which I'm hoping
gives a little more information than just the "or die print $!"; So,
now I'm just waiting for it to fail again.

Here's another little bit of information, which also doesn't make sense
to me.
This problem happened at the same site over 2 1/2 years ago. Because
the script creates mutiple sockets, I wasn't sure which subroutine it
was in when it died. So, I added some print "in sub xxxx" statements
to each subroutine. While running with that "debug" script, the error
didn't occur. All I did was add print statements. Now, same site but
a new server and the print statements aren't helping anymore.
 
S

Sisyphus

..
..
All I did was add print statements. Now, same site but
a new server and the print statements aren't helping anymore.

Sounds like something might be configured a little differently on the new
server and the print()ing is going somewhere else. Try opening a filehandle
to a log file, and have the debug statements print() to that filehandle.

(Or perhaps those print statements are already being written to some error
log ?)

Cheers,
Rob
 
T

ten8ciousb

Sisyphus said:
.
.

Sounds like something might be configured a little differently on the new
server and the print()ing is going somewhere else. Try opening a filehandle
to a log file, and have the debug statements print() to that filehandle.

(Or perhaps those print statements are already being written to some error
log ?)

I only mentioned the print statements because I thought it was strange
that they magically made the problem go away. The debugging print
statements still show up in the log, but whatever effect they were
having before, which prevented the "Can't locate.." message, they
aren't having now. The only thing that I can think they did was slow
down the execution of the program.
 
B

Bart Van der Donck

ten8ciousb said:
Sometimes, not always, an attempt to create a new socket connection
fails with this message:
Socket::INET" (perhaps you forgot to load "IO::Socket::INET"?) at
/usr/local/lib/perl5/5.6.1/IO/Socket/INET.pm line 32

You could use eval to check whether a module is loaded:

eval ('use aModule;');
die 'aModule not loaded' if $@;
Any ideas why or how INET.pm fails saying it can't find new in INET.pm?
The script runs on many servers many times a day, but only fails on one
and generally about the same time of the day. Okay. Seems kind of
obvious that is something specific to the server and the time of day.
But, within the same script there are multiple calls to create sockets
to different servers and they complete successfully.

I'm kind of out of my element on the internals of perl here, but my
thoughts:
Is it trying to find IO::Socket::INET.pm in @INC in order to identify
the super class, which is IO::Socket?
Does that mean that @INC has somehow become 'corrupted' during runtime?

any other thoughts.
Or has perl's symbol table become corrupted so it doesn't know what
"new" is?

Not sure if this would make any difference, but saying use lib
'/path/to/...'; in the beginning of your script wouldn't harm.

You could also tell the program to explicitly run under Perl 5.6.1.

Maybe there is a lock or buffering issue while reading INET.pm into
memory with mutliple sockets. There's a note from the IO::Socket and
IO::Socket::INET man pages saying:

"As of VERSION 1.18 all IO::Socket objects have autoflush turned
on by default. This was not the case with earlier releases."

Just some ideas - maybe it helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,732
Latest member
ArronPalin

Latest Threads

Top