question about asynchronous development

This is a discussion on question about asynchronous development within the SNMP Users forums, part of the Networking and Network Related category; Hi, (sorry for the bad English) I'am developping a C program with NET-SNMP. This program collects SNMP data ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2007
ggff pp
 
Posts: n/a
Default question about asynchronous development

Hi,
(sorry for the bad English)

I'am developping a C program with NET-SNMP.
This program collects SNMP data from a large number of targets.

There are two designs:
1) synchronous and multi-threads
one thread do a sysnchronous collection from one target
demo: http://net-snmp.sourceforge.net/wiki...nc_Application
2) asynchronous
use asynchronous send function like the demo on the website
Which one is better? (stable, faster ...)
Or any other better design?

Then, some problem about asynchronous send function:
1) I know there is a call-back function.
Does the call-back function run multi-instances. (like multi-threads)
2) When will the call-back function run?
After snmp_read() ?
Or whenever a response is received? (even before the second snmp_send())
3) I don't quite understand the code below. (these code comes from the demo)
>/* loop while any active hosts */
> while (active_hosts) {
> int fds = 0, block = 1;
> fd_set fdset;
> struct timeval timeout;
>
> FD_ZERO(&fdset);
> snmp_select_info(&fds, &fdset, &timeout, &block);
> fds = select(fds, &fdset, NULL, NULL, block ? NULL :

&timeout);
> if (fds < 0) {
> perror("select failed");
> exit(1);
> }
> if (fds)
> snmp_read(&fdset);
> else
> snmp_timeout();
> }

Why we need this part of code? Whitout these code, will the
call-back function work?
Will these code block themselves when no response is received?
Or cost all CPU resource?

Thanks,
pgf
email: pgf00a@gmail.com

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?p...rge&CID=DEVDEV
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:31 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0