I've did what you proposed, and the error was gone, but of course new one 
occured. The ones I have now are for this part of the code: 
void initialize (void)
{
struct o_id *op = oids;

/* Win32: init winsock */
SOCK_STARTUP;

/* initialize library */
init_snmp("asynchapp");

/* parse the oids */
while (op->Name) {
op->OidLen = sizeof(op->Oid)/sizeof(op->Oid[0]);
if (!read_objid(op->Name, op->Oid, &op->OidLen)) {
snmp_perror("read_objid");
exit(1);
}
op++;
}} when parsing the oid I get: g++ -I/usr/local/include -I/usr/include/mysql -g 
  -c Testincpp.cpp -o Testincpp.oTestincpp.cpp: In function `void 
initialize()':Testincpp.cpp:74: error: invalid conversion from `int*' to 
`size_t*'Testincpp.cpp:74: error:   initializing argument 3 of `int 
read_objid(const char*, oid*, size_t*)' And for: 
void asynchronous(void)
{
struct session *hs;
struct host *hp;

/* startup all hosts */

for (hs = sessions, hp = hosts; hp->name; hs++, hp++) {
struct snmp_pdu *req;
struct snmp_session sess;
snmp_sess_init(&sess); /* initialize session */
sess.version = SNMP_VERSION_2c;
sess.peername = strdup(hp->name);

// unsigned char comm[50]= hp->community;

sess.community = strdup(hp->community); 
sess.community_len = strlen(hp->community);
sess.callback = asynch_response; /* default callback */
sess.callback_magic = hs;
if (!(hs->sess = snmp_open(&sess))) {
snmp_perror("snmp_open");
continue;
}
hs->current_oid = oids;
req = snmp_pdu_create(SNMP_MSG_GET); /* send the first GET */
snmp_add_null_var(req, hs->current_oid->Oid, hs->current_oid->OidLen);
if (snmp_send(hs->sess, req))
active_hosts++;
else {
snmp_perror("snmp_send");
snmp_free_pdu(req);
}
}

/* 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();
}

/* cleanup */

for (hp = hosts, hs = sessions; hp->name; hs++, hp++) {
if (hs->sess) snmp_close(hs->sess);
}}  When giving the hp->community to the sess.community, I get: Testincpp.cpp: 
In function `void asynchronous()':Testincpp.cpp:309: error: invalid conversion 
from `char*' to `u_char*' How can I fix that? Thanks a lot for  your help 
Christophe> Date: Wed, 30 Jul 2008 10:06:38 -0400> From: [EMAIL PROTECTED]> To: 
[EMAIL PROTECTED]> CC: net-snmp-coders@lists.sourceforge.net> Subject: Re: 
net-snmp and C++> > On Wed, Jul 30, 2008 at 04:39:44PM +0300, Christophe Melki 
wrote:> > > Then I tried to program a C++ API to get it to poll several server 
> > using snmp agents and gather information in a database. On the > > net-snmp 
> > tutorial website, there is a example code about asynchronous polling > > 
which is perfect for my demand, but is coded in C.> > I tried compiling it with 
C++, but I get one error that makes my > > application fail, and this error 
does not show if I compile in C.> > It's a namespace thing.> > > struct oid {> 
> const char *Name;> > oid Oid[MAX_OID_LEN];> > int OidLen;> > }> > [excerpted 
error message]> > > g++ -I/usr/local/include -I/usr/include/mysql -g -c 
Testincpp.cpp > > -o Testincpp.oTestincpp.cpp:41: error: conflicting 
declaration 'struct > > oid'/usr/include/net-snmp/types.h:47: error: 'oid' has 
a previous > > declaration as `typedef u_long oid'> > The struct named 'oid' is 
colliding with the typedef for 'oid'. Change > the struct name and you should 
be good to go.> -- > Roy M. Silvernail is [EMAIL PROTECTED], and you're not> "A 
desperate disease requires a dangerous remedy."> - Guy Fawkes> 
http://www.rant-central.com> 

_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to