Operating System - HP-UX
1752777 Members
5919 Online
108789 Solutions
New Discussion юеВ

Re: terminate the connection

 
SOLVED
Go to solution
peterchu
Super Advisor

terminate the connection

I am running some program that connect from 192.168.0.2 to 192.168.0.1 through the port 1186 , but in the host 192.168.0.1 found that the port 1186 is occupied by 192.168.0.2 ( there are three sessions ) , now host 192.168.0.1 can't connect one more session , it may be because the max. limit of session is full , can suggest how to erase this "CLOSE_WAIT" connection at 192.168.0.1 ? thx.



At 192.168.0.1

# netstat -na |grep 1186
tcp 0 0 0.0.0.0:1186 0.0.0.0:* LISTEN
tcp 1 0 192.168.0.1:1186 192.168.0.2:32783 CLOSE_WAIT
tcp 1 0 192.168.0.1:1186 192.168.0.2:32776 CLOSE_WAIT
tcp 1 0 192.168.0.1:1186 192.168.0.2:32787 CLOSE_WAIT

3 REPLIES 3
Vijeesh CTK
Trusted Contributor
Solution

Re: terminate the connection

Hi,

If you have lsof on your system , you can kill those close_wait session.

lsof -i portno will show the process ID .

Cheers

CTK
peterchu
Super Advisor

Re: terminate the connection

thx CTK ,

it works , thx a lot.
rick jones
Honored Contributor

Re: terminate the connection

99 times out of 10, CLOSE_WAIT is an application-level bug. It means that on the side where the CLOSE_WAIT's exist, the application received a connection termination notification from the remote (eg read return of 0) but then did not call close() itself.

Terminating the process(es) kludges around the application bug because in Unix, process termination causes the files (eg sockets) to be closed.

Best to fix the application(s).

And, if the problem includes not being able to restart an instance of a server - its bind fails - that implies there is also a bug there - the server program should be setting SO_REUSEADDR with setsockopt() before trying to bind() to its well-known port number(s).
there is no rest for the wicked yet the virtuous have no pillows