java.io.IOException: Invalid argument

        使用SNMP4J發送告警時,突然出現下面這樣的異常:

java.io.IOException: Invalid argument
        設置定發送端綁定IP和端口,如下:

// 設置管理進程的IP和端口
String address = "udp:172.16.54.77/1162";
logger.info("[SnmpSender.static] Init snmpTrap.Set remote address: " + address);
Address targetAddress = GenericAddress.parse(address);
TransportMapping transport = null;
try {
	UdpAddress localUdpAddress = new UdpAddress("172.16.54.78/0");
	transport = new DefaultUdpTransportMapping(localUdpAddress);
	snmpTrap = new Snmp(transport);
	transport.listen();
} catch (IOException e) {
	logger.error("[SnmpSender.static] Error while init snmpTrap response: " + e.getMessage(), e);
}
          如果在localUdpAddress中設置的IP地址爲0.0.0.0,則發送告警時就會報:java.io.IOException: Invalid argument,參見如下DatagramSocket

          

         另外,可能出現java.io.IOException: Invalid argument的情況,也可參考下:http://blog.csdn.net/clariones/article/details/6682526

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章