[SNMP4J] TCP Port not closed when invoked transport.close method

Vijay Reddy (dvsreddy) dvsreddy at cisco.com
Thu Jul 12 00:30:14 CEST 2007


Hi,
 
Am trying to write SNMP TCP Trap receiver program. Am able to receive
traps, but when tried to close the connection,  still the TCP port is
listening mode.
 
 
Can you please let me know if anything wrong in my code as provide
below, Am working in Eclipse IDE, port is released only when closing the
Eclipse IDE.
 
 
private synchronized void listen(IPAddress receiverIp , int
connectionType, int dest_port ) throws IOException, InterruptedException
{

String sourceIp = receiverIp.getIPAddress()+ "/"+dest_port; 

Snmp snmp = null; 

if (connectionType == TrapConstants.TCP) {

transport = new DefaultTcpTransportMapping(new TcpAddress(sourceIp));

} else { 

transport = new DefaultUdpTransportMapping(new UdpAddress(sourceIp));

}

ThreadPool threadPool =

ThreadPool.create("DispatcherPool", NUMBER_OF_THREADS);

MessageDispatcher mtDispatcher =

new MultiThreadedMessageDispatcher(threadPool, new
MessageDispatcherImpl()); 

mtDispatcher.addMessageProcessingModel(new MPv2c()); 

snmp = new Snmp(mtDispatcher, transport); 

snmp.addCommandResponder(this);

transport.listen();

LogManager.getTextLog().debug("Listening on "+sourceIp); 

}

public synchronized void processPdu(CommandResponderEvent event) {

PDU command = event.getPDU(); 

if (command != null) { 

receivedEventList.add(command);

}

}

public void close() throws IOException {

transport.close();   // Call is successfull  but doesn't release the
port immediately.

}

 
 
 
Thanks and regards,
Vijay



More information about the SNMP4J mailing list