1833832 Members
2414 Online
110063 Solutions
New Discussion

Socket and Port problem

 
SOLVED
Go to solution
Alex Lavrov
Regular Advisor

Socket and Port problem

Hello,
I have a N Class HPUX 11.00 server. Another server was connected to this server on port 5000 and then the service died, but the socket seems to be alive, because the first server cannot bind to this port.

[196] srv1 # lsof -i:5000
[197] srv1 # netstat -a | grep 5000
tcp 0 0 srv1.5000 srv2.1557 ESTABLISHED

lsof returns me nothing, how can I kill this socket to free this port?

thanx.

7 REPLIES 7
Massimo Bianchi
Honored Contributor
Solution

Re: Socket and Port problem

twang
Honored Contributor

Re: Socket and Port problem

To clear such socket connections, you can

1. Use ndd to force close the connection
Take a look at this thread(Steven gave the solution):
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xbe06a22d6d27d5118fef0090279cd0f9,00.html


2. Find the IP of the remote connection and reboot it (if it is a PC).
Alex Lavrov
Regular Advisor

Re: Socket and Port problem

I think it's what I need, but now I have a problem to find this connection, tcp_status gives me a lot of output, I tried to convert IP and PORT to HEX, but none of these strings do not appera there, any ideas?
thanx.
Massimo Bianchi
Honored Contributor

Re: Socket and Port problem

Always from the same thread:

or 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"




using address information, that you have, should solve the problem. just resolv srv1 and srv2 to hex, like in the example.

Massimo
Massimo Bianchi
Honored Contributor

Re: Socket and Port problem

forgetting:

197] srv1 # netstat -a | grep 5000
tcp 0 0 srv1.5000 srv2.1557 ESTABLISHED

here you have the info !

Massimo
Zigor Buruaga
Esteemed Contributor

Re: Socket and Port problem

Hi,

From the same example:

# 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

Note that remote IP is not in HEX format, in this case is 015.043.233.086.

Kind regards,
Zigor
rick jones
Honored Contributor

Re: Socket and Port problem

While us of the ndd kludge may treat the symptom, it will not cure the disease, which likely as not is a broken server application. Server applications should set SO_REUSEADDR before trying to bind() to their well-known port numbers. This will allow them to be restarted while there are old endpoints in any state other than listen.
there is no rest for the wicked yet the virtuous have no pillows