Basic snmp_sess_close and snmp_session question

Nishikant Deshmukh <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <CAJP1gCVfvFz6g2GjoHqYsD=AWVpDvtyB47rj9-Nk+o3LvHhybA@mail.gmail.com>
Hi,

In the example code in README.thread under Single API use

http://www.net-snmp.org/docs/README.thread.html

1) Can an snmp_pdu be cloned and sent to multiple sessions?

2)

If we are getting data in a loop, can we create SNMP PDU attach them to
snmp_session created before the loop and release memory of snmp_session and
close void * sessp after the loop? In short can the same snmp_session and
void *sessp be used for multiple PDUs? Or we have to allocate both
snmp_session and void *sessp for each PDU?

netsnmp_session *session = (netsnmp_session *) malloc
(sizeof(netsnmp_session);

snmp_sess_init(session);

void *sessp = snmp_sess_add(session, netsnmp_client, NULL, NULL);

while (data)

{

   ...create pdu

   ...Attach data to pdu

   if (0 == snmp_sess_send(sessp, pdu)) {
          snmp_sess_error(sessp, &liberr, &syserr, &errstr);
          printf("SNMP write error %s.\n", errstr);
          free(errstr);
          return 0;
   }

}


snmp_sess_close(sessp);



Best Regards,
Nishikant Deshmukh

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.