I had a similar problem recently with a database which refused to release a port on my HPUX 11 server. Our unix admins were unable to come up with a solution so I spent some time browsing for a solution. I found the following:
"Find the TCP instance data and then use tcp_discon to remove the instance as follows:
# ndd -get /dev/tcp tcp_status
TCP dest snxt suna swnd cwnd rnxt rack rwnd rto mss [lport,fport] state
0183b8b4 015.043.233.086 533cb8ce 533cb8ce 00008000 00003000 533bc583 533bc583
00000000 02812 04096 [c00a,cea9] TCP_CLOSE_WAIT
So, if you wanted to remove this connection:
# ndd -set /dev/tcp tcp_discon 0x0183b8b4
If you want to use the tcp_discon_by_addr, you use a 24 byte string that contains the hex representation of the quadruple.
For example, if the connection that I want to delete is:
Local IP: 192.1.2.3 (0xc0010203)
Local Port: 1024 (0x0400)
Remote IP : 192.4.5.6 (0xc0040506)
Remote Port: 2049 (0x0801)
The "hex" string you pass to tcp_discon_by_addr is:
# ndd -set /dev/tcp tcp_discon_by_addr "c00102030400c00405060801"
NOTE: the preceding 0x that typically indicates a Hex number is NOT part of the string passed"
I have as yet been unable to test this out for myself so I cannot confirm that it works. If you manage to substantiate it please do let me know!