in reply to Fast database access using DBM::Deep help

My first thought is that it doesn't retrieve the details needed from the database quick enough to create the IO::Socket::Inet connection.

Without further explanation, that statement doesn't appear to make much sense. There is no way to arrive at the line that (attempts to) open the socket, before the preceding statements that provide the information to make that connection have completed.

What does make sense is that the attempt to create the socket connection is failing for some reason, thus when you get to the erring line, $dusky is still undefined.

The appropriate course of action would be to add error checking to the socket creation:

my $dusky = IO::Socket::INET->new( PeerAddr => $duskyip, PeerPort =>$duskymoxaport, Proto => 'tcp', T +imeout => 1 ) or warn "Connection to $duskyip:$duskymoxaport failed because $!/$^E +" and next XXX;

That would probably give you a good clue as to why the connection is failing (and is good practice anyway!).

A likely candidate for the failure is that your 1 second timeout sometimes isn't enough when you've just opened connections to 30-odd previous machines and the network/stack is very busy. You might just need to extend the timeout; or perhaps add a retry loop.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Fast database access using DBM::Deep help
by Doozer (Scribe) on Aug 07, 2013 at 14:04 UTC
    Thanks a lot!!

    If anything this has helped to uncover what is causing the error. I randomly get "Connection Refused" messages. This largely points to the Moxa devices so I am currently playing around with the settings to allow more than 1 connection at a time. It seems silly that I missed such a simple thing as error checking. At least it means there isn't an issue with the database file or the hash.

    Much appreciated :)