[SNMP4J] Clarification reqd regarding TransportMapping ..

Vaibhav Rane vaibhavrane at hotmail.com
Thu Feb 16 11:07:13 CET 2006


Hello Guys,

I am trying to execute the foll code. I provide the 
defaultUdpTransportMapping while creating the Snmp object. while sending the 
udp packet i get a null pointer exception. Please correct me in the code.

I would like to thank frank for helping me with my earlier query.

public static void main(String[] args)
        {
                try
                {
                UdpAddress udpAdd = new UdpAddress();
                Address add = udpAdd.parse("udp:192.168.0.129/161");
        //      Address add = udpAdd.parse("192.168.0.129");


                PDU pdu = new PDU();
                pdu.add(new VariableBinding(new OID(".1.3.6.1.2.1.1.1"))); 
// sysDescr
                pdu.add(new VariableBinding(new OID(".1.3.6.1.2.1.2.1"))); 
// ifNumber
                pdu.setType(PDU.GETNEXT);

                CommunityTarget target = new CommunityTarget();
                target.setCommunity(new OctetString("public"));
                target.setAddress(add);
                target.setVersion(SnmpConstants.version1);

                Snmp snmp = new Snmp(new DefaultUdpTransportMapping());

                //Following Line throws Null pointer exception
ResponseEvent response = snmp.send(pdu, target);

                if (response.getResponse() == null) {
                    System.out.println("Request Timed Out");
                    // request timed out
                }
                else {
                    System.out.println("Received response from: "+
                    response.getPeerAddress());
                    // dump response PDU
                    System.out.println(response.getResponse().toString());
                }
                }
                catch(IOException e)
                {
                        System.out.println("Excep = " + e);
                }
        }

Thanking in advance.

Regards,
Vaibhav

_________________________________________________________________
NRIs Zero balance Account. FREE Money Transfers with FREE DVD 
https://www.online.citibank.co.in/portal/rca_msntagofline.htm




More information about the SNMP4J mailing list