

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.net-snmp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=TUT%3ASimple_Perl_Async_Application</id>
		<title>TUT:Simple Perl Async Application - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.net-snmp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=TUT%3ASimple_Perl_Async_Application"/>
		<link rel="alternate" type="text/html" href="http://www.net-snmp.com/wiki/index.php?title=TUT:Simple_Perl_Async_Application&amp;action=history"/>
		<updated>2026-05-12T12:34:09Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>http://www.net-snmp.com/wiki/index.php?title=TUT:Simple_Perl_Async_Application&amp;diff=3298&amp;oldid=prev</id>
		<title>Rstory at 19:52, 26 February 2008</title>
		<link rel="alternate" type="text/html" href="http://www.net-snmp.com/wiki/index.php?title=TUT:Simple_Perl_Async_Application&amp;diff=3298&amp;oldid=prev"/>
				<updated>2008-02-26T19:52:29Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Q: in the documentation i can see that the get function takes a second option argument which is the callback function, how does it work ?&lt;br /&gt;
&lt;br /&gt;
* as an example...&lt;br /&gt;
 $result = $sess-&amp;gt;get([[&amp;quot;sysDescr&amp;quot;,&amp;quot;0&amp;quot;]], [\&amp;amp;cb1, $sess]);&lt;br /&gt;
 // or without the session pointer, it would look like:&lt;br /&gt;
 $result = $sess-&amp;gt;get([[&amp;quot;sysDescr&amp;quot;,&amp;quot;0&amp;quot;]], [\&amp;amp;cb1]);&lt;br /&gt;
** cb1 is a function that is called back (and $sess is passed as an argument to it along with the normal ones)&lt;br /&gt;
** after you call the above, it&amp;#039;ll return immediately.&lt;br /&gt;
** You need to call SNMP::MainLoop(); to get it to wait for packets to arrive.&lt;br /&gt;
** when packets arrive, the callback will be called.&lt;br /&gt;
** eg&lt;br /&gt;
 sub cb1{&lt;br /&gt;
   my $sess = shift; // only if you passed sess above&lt;br /&gt;
   my $vlist = shift;&lt;br /&gt;
   // ...&lt;br /&gt;
** you can have mulitple outstanding requests (ie, call get() on a bunch of requests and they&amp;#039;ll all be sent out and the callback will be called multiple times)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: so the callback function receives two arguments?&lt;br /&gt;
* it receives 1 + anything else you pass it. (in the example above, it passes it a &amp;quot;sess&amp;quot; pointer so it gets it back.) normally it&amp;#039;s just the varbind list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other code you can look at:&lt;br /&gt;
* np-collectd in the net-policy project&lt;br /&gt;
* perl/SNMP/SNMP.pm in &amp;quot;gettable&amp;quot;&lt;br /&gt;
* perl/SNMP/t/async.t [worst case :-)]&lt;br /&gt;
&lt;br /&gt;
Also run &amp;quot;perldoc SNMP&amp;quot;, and read the section on &amp;quot;Acceptable callback formats&amp;quot;&lt;/div&gt;</summary>
		<author><name>Rstory</name></author>	</entry>

	</feed>