Menu

#1247 socket(): Bad file descriptor

windows
closed
nobody
None
5
2012-11-08
2004-11-18
Anonymous
No

ActivePerl 5.6.1.638
Windows XP v2002 SP1
IE6.0.2800.1106 SP1
Command: Net::SNMP->session()
<script language="PerlScript">
use Net::SNMP;
After a few minutes of operation, my script starts to
give the follwing error to my Net::SNMP->session
command: socket(): Bad file descriptor
The only fix is to close the IE6 and open the HTM fresh.
Then after a few minutes it happens again.

sub GetSysname_onClick
{
$community="xxxxx";
$SysName="1.3.6.1.2.1.1.5.0";
$IPAddress="1.1.1.1";
($session,$error)=Net::SNMP->session(-
hostname=>$IPAddress,-community=>$community);
if (!defined($session)) {
$window->document->MyForm->Error->{'value'}
="Error Opening SNMP Session:".$error;
exit 1; }
}

Discussion

  • Nobody/Anonymous

    Logged In: NO

    It looks like the Bad file descriptor message is an error retval
    from IO::Socket::INET->new
    Therefore I don't think this is a problem with Net::SNMP
    DOS perl is OK. Looks to only affect PerlScript.
    The following code loops 1014 times before the Bad File
    Descriptor happens.

    <script language="PerlScript"> use Net::SNMP; $Community="public"; $IPAddress="1.1.1.1"; $MaxSessions=2000; $Sessions=0; for \($Sessions=1;$Sessions<=$MaxSessions;$Sessions++\) \{ \($session,$error\)=Net::SNMP->session\(- hostname=>$IPAddress,-community=>$Community\); if \(\!defined\($session\)\) \{ $window->document->MyForm->Error->\{'value'\}="Error Opening SNMP Session:".$error; $Sessions=$MaxSessions; \} else \{ $Sessions++; $window->document->MyForm->Status->\{'value'\} ="Session\#".$Sessions; $session->close\(\); \} \} </script>

    Work Continues.....

     
  • Nobody/Anonymous

    Logged In: NO

    I have removed the call to $session->close() and I no longer
    get the error. So it is seems that something about the close
    function is the problem.
    I guess that the removal of the close functions is not a good
    workaround because I would expect to run out of memory at
    some point. I have 20000 sessions open so far with no
    problems.

     
  • Robert Story

    Robert Story - 2004-11-22

    Logged In: YES
    user_id=76148

    Net::SNMP is not part of the Net-SNMP package, which has
    it's own (differnt) perl module. You'll have to contact the
    authors of the Net::SNMP perl module for support.

     

Log in to post a comment.