why is it possible? Here, I am going to learn more about SNMP. The Program is running normally. If SNMP get is called successfully, my time-out is reached. Code is as follows.
# Include "snmp_pp.h" # include "iostream. H "# define sysdescr" 1.3.6.1.2.1.1.1.0 "// Object ID for system descriptorvoid main () {SNMP: socket_startup (); // socket_startup () static member function, initialize the function int status of winsocket; // return status ctarget (IPaddress) "192.168.1.74 "); // SNMP ++ V1 target // use an address object to construct a ctarget object VB (sysdescr); // SNMP ++ variable binding PDU; // SNMP ++ PDU // ------- [constru CT a SNMP ++ SNMP object] ----------------------------------------- SNMP (Status); // create a SNMP ++ session to create a new SNMP object. // The first parameter indicates the creation status, 0 indicates that if (status! = Snmp_class_success) {// check creation status cout <SNMP. error_msg (Status); // If fail, print error string return ;} // ------- [invoke a SNMP ++ get] ------------------------------------------------------- // invoke means requests help or protection (from a deity) PDU + = Vb; // Add the variable binding if (status = SNMP. get (PDU, ctarget ))! = Snmp_class_success) cout <"failed to get \ n" <SNMP. error_msg (Status); else {PDU. get_vb (VB, 0); // extract the variable binding cout <"system descriptor =" <VB. get_printable_value () ;}// print out SNMP: socket_cleanup (); // socket_cleanup () static member function to release the winsocket resources initialized by the above function}
Find out the cause of SNMP request time out through this website. It turns out to be the cause of community. Just change it to the communiry corresponding to the switch. If it is get, it should be get community.