I'm unable to open new netsnmp_transport* after closing the old one.

[email protected] Thu, 14 Oct 2021 09:28:33 -0400
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi,

Net-SNMP Version: 5.9

I'm making a small SNMP Client and I'm currently implementing Traps and 
Notifications. I'm following the snmptrapd for guidance. But now I 
require to stop/start the listener on specific port.

I'm initializing like this:

     port = "udp:162";
     netsnmp_transport *tr = netsnmp_transport_open_server("myapp", 
port);
     // ... checks
     AddSession(tr);  // add transport to opened snmp_session i.e. 
snmp_add(...)

This works normally, but when I stop the listener and free the 
transport. I can't open server again as the return value is always NULL

     // ... close session
     netsnmp_transport_free(tr);
     // ... checks
     tr = netsnmp_transport_open_server("myapp", port);  // returns NULL

errno is set to 2. (errno 2 ("No such file or directory"))
Which I presume means that port is already open?

So what is the preferred way to initialize and open and close listening 
ports with Net-SNMP?


I also enabled logging with "tdomain".
This is the tdomain log for opening and closing transport 3 times. The 
last time is when I try to reopen port 16112

     tdomain: tdomain_transport_spec("SNMP Navigator", "udp:16112", 1, 
"[NIL]", "[NIL]", "[NIL]")
     tdomain: Found domain "udp" from specifier "udp"
     tdomain: trying domain "udp" address "16112" default address "[NIL]"
     tdomain: tdomain_transport_spec("SNMP Navigator", "udp:16117", 1, 
"[NIL]", "[NIL]", "[NIL]")
     tdomain: Found domain "udp" from specifier "udp"
     tdomain: trying domain "udp" address "16117" default address "[NIL]"
     tdomain: tdomain_transport_spec("SNMP Navigator", "udp:16112", 1, 
"[NIL]", "[NIL]", "[NIL]")
     tdomain: Found domain "udp" from specifier "udp"
     tdomain: trying domain "udp" address "16112" default address "[NIL]"
     couldn't open udp:16112 -- errno 2 ("No such file or directory")


Thanks,
Dario


_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users