[SNMP4J] [BULK] SNMP port setting for pulling (Michael Yap)

Tan Yeu Ming tanym4 at gmail.com
Thu Sep 17 12:07:33 CEST 2009


I manage to set the desire source port to 2000, just added this code
"new UdpAddress(2000)"
Below show the code before modify and after modify. Anyone can give
comment on this code? Any concern could be rise up or enchancement
that can be apply?

Before:
try {
	transport = new DefaultUdpTransportMapping();
} catch (IOException e1) {
	System.out.println(e1.getMessage());
	e1.printStackTrace();
}
snmp = new Snmp(transport);
usm = new USM(SecurityProtocols.getInstance(),
		new OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
try {
	transport.listen();
} catch (IOException e1) {
	e1.printStackTrace();
}
After:
try {
	transport = new DefaultUdpTransportMapping(new UdpAddress(2000));
} catch (IOException e1) {
	System.out.println(e1.getMessage());
	e1.printStackTrace();
}
snmp = new Snmp(transport);
usm = new USM(SecurityProtocols.getInstance(),
		new OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
try {
	transport.listen();
} catch (IOException e1) {
	e1.printStackTrace();
}

-- 
Thanks and Regards,
Samuel Tan
tanym4 at gmail.com



More information about the SNMP4J mailing list