I have written code to create threads with the information need to start an SNMP session in each thread.
my $thr = threads->create(\&test,"host","string","2");
when I involve more than one thread I only get information back from one thread as if all other sessions were stopped. Here is part of the code involved in addition to the snippet above.
sub test{ my ($SNMP_TARGET, $SNMP_COMMUNITY,$SNMP_VERSION) = @_; my $SESSION = new SNMP::Session (DestHost =>$SNMP_TARGET, Community =>$SNMP_COMMUNITY, Version => $SNMP_VERSION ); my $VLIST = new SNMP::VarList(['sysDescr',0], #0 ['sysObjectID',0], #1 ['sysUpTime',0], #2 ['sysContact',0], #3 ['sysName',0], #4 ['sysLocation',0], #5 ['sysServices',0]); #6 my @a = $SESSION->get($VLIST); print "$a[0]\n"; }
Using fork() has been recommended to me before, I really want to use threads, so any help in getting the required solution will be great! Thank you in advance

In reply to threads and SNMP Session by Otogi

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.