[SNMP4J] how to get the value of response?

zied.majed zied.majed at laposte.net
Mon May 17 15:00:29 CEST 2004


Hi everybody,
I ve just downloaded snmp4j to use it but i have some problem
to access to the response ; for example:
****************************************************
public class zied
{
public static void main (String args[])
 {
  Snmp mysnmp = null;
  try {
  mysnmp = new Snmp(new DefaultUdpTransportMapping());
  } catch(Exception e) {e.printStackTrace();}
  PDU mypdu = new PDU();
  mypdu.add(new VariableBinding(new
OID("1.3.6.1.2.1.1.1.0")));    //sysdescr.0
  UdpAddress adr = null;
  try {
  adr = new UdpAddress(InetAddress.getByName("10.0.0.11"), 161);
  
  } catch(Exception e) {e.printStackTrace();}

  CommunityTarget ctarg = new CommunityTarget();
  ctarg.setAddress(adr);
  ctarg.setVersion(SnmpConstants.version2c);
  ctarg.setCommunity(new OctetString("public"));
  ctarg.setTimeout(5000);
  ctarg.setRetries(3);
  try {
  PDU resp = new PDU();
  MyRespoListen rl =   new MyRespoListen();
  Object useHandle = new Object();
  mysnmp.sendPDU(mypdu,ctarg, useHandle, rl );
  if (resp == null)
    System.out.println("resp= null");
  else
    System.out.println(resp.(...?));

  }
  catch(Exception e)
{
  e.printStackTrace();
}

  System.exit(0);
 }
}
******************************************************
System.out.println(resp.(...?)): what should i do to access to
the value ("cisco" for example)?
Thank you in advance for your help


Accédez au courrier électronique de La Poste : www.laposte.net ; 
3615 LAPOSTENET (0,34€/mn) ; tél : 08 92 68 13 50 (0,34€/mn)






More information about the SNMP4J mailing list