[SNMP4J] Exception thrown in DefaultTcpTransportMapping
Frank Fock
fock at agentpp.com
Fri Mar 23 20:31:46 CET 2007
Hi Rodger,
Solaris does not release a TCP port immediately after it
is closed. The port remains in TIME_WAIT. See
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setReuseAddress(boolean)
for details.
Best regards,
Frank
Rodger Lucas wrote:
> Hi:
>
> I came across this while running junit testcases where I was
> initializing and unitializing SNMP4J objects. The following code causes
> an exception when using DefaultTcpTransportMapping but not when using
> DefaultUdpTransportMapping.
>
> Consider the following code below. There are two methods which create an
> org.snmp4j.Snmp object sequentially with the appropriate cleanup/close
> in between. One method uses DefaultUdpTransportMapping and the other
> DefaultTcpTransportMapping. I have commented where the Exception is
> thrown.
>
> When running the test program we see the following in the console:
>
> --------BEGIN CONSOLE OUTPUT --------------
> Start testUdp
> First startup
> First sleep
> First shutdown
> Second startup
> Second sleep
> Second shutdown
> End testUdp
>
> Start testTcp
> Second startup
> First sleep
> First shutdown
> Second startup
> Exception in tcp test: java.net.BindException - Address already in use
> java.net.BindException: Address already in use
> at sun.nio.ch.Net.bind(Native Method)
> at
> sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119
> )
> at
> sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
> at
> sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
> at
> org.snmp4j.transport.DefaultTcpTransportMapping$ServerThread.<init>(Unkn
> own Source)
> at
> org.snmp4j.transport.DefaultTcpTransportMapping.listen(Unknown Source)
> at com.tazz.proto.TestTwo.testTcp(TestTwo.java:126)
> at com.tazz.proto.TestTwo.main(TestTwo.java:159)
> End testTcp
> --------END CONSOLE OUTPUT --------------
>
> I am using SNMP4J.jar version 1.8.1
>
> Java VM is:
> java version "1.5.0_07"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_07-b03, mixed mode)
>
> Hardware / OS: SunOS psd0a01 5.10 Generic_118855-15 i86pc i386 i86pc
>
> Interestingly when this same program is run on Windows XP the exception
> is NOT thrown.
>
...
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list