Operating System - HP-UX
1833866 Members
2445 Online
110063 Solutions
New Discussion

Re: Address already in use bind error

 
David Schumacher
Occasional Contributor

Address already in use bind error

I have a threaded process with a signal handler that supports the HUP signal. Upon receiving this signal a UDP socket that is used to communicate with another "backup" process is closed (using shutdown() followed by close()). The process then attempts to open and bind to this socket. A test that continuously REHUPs the process every two minutes ran successfully for several hours. Eventually, however, the bind fails due to address already in use. Is it possible that the close is not complete even though it returns - ie. the O/S has some cleanup to perform?
3 REPLIES 3
Mark Greene_1
Honored Contributor

Re: Address already in use bind error

have you tried tracing this with periodic netstats to try and catch the collision on the socket in the act?

--
mark
the future will be a lot like now, only later
Ron Kinner
Honored Contributor

Re: Address already in use bind error

take a look at netstat -an |grep x

where x is your port number and see how many connections you still have open.

Are they perhaps all stuck in FIN_WAIT_2?

If it is a lot you may want to do

netstat -an |grep x|wc -l
which will count them for you.

Are you using 11.0 or 10.x? NDD in 11.0 can increase the number of possible connections.

nettune is the equivalent on 10.

Ron






manoj_pu
Regular Advisor

Re: Address already in use bind error


Hello

Try to find any process is running on that particular port by using lsof utility.

#lsof -i |grep < port no>

Then kill that process and restart the program again hope it should work

Rgds

Manoj

Leave with out tense and try best you gets result