Operating System - HP-UX
1834879 Members
1980 Online
110071 Solutions
New Discussion

Cannot create socket because port is busy

 
SOLVED
Go to solution
Deepak_3
Occasional Contributor

Cannot create socket because port is busy

Hi,

We are trying bind a socket in our appication
it gives a bind error saying that port is
busy.This is on HPUX-11.0

When we do netstat -n , we cannot get any
information regarding that particular port is being used.

Do anyone have any clue what the problem is ?

Thanks and Regards
Deepak
2 REPLIES 2
Denver Osborn
Honored Contributor

Re: Cannot create socket because port is busy

try using netstat -an to see if the port already exists and is in a LISTEN state.

have you attempted to telnet to the port?
# telnet host port_number

also look for the port number in /etc/services and /etc/inetd.conf
James R. Ferguson
Acclaimed Contributor
Solution

Re: Cannot create socket because port is busy

Hi:

While 'netstat -an' will show you the ports in use, you will need 'lsof' to determine what process is bound to the port.

A very interesting site on UNIX socket programming is:

http://www.lcg.org/sock-faq/

It is generally easier if you don't bind() a port number in your client program, but rather let the system choose one with the connect() call. A discussion of this appears here:

http://www.lcg.org/sock-faq/detail.php3?id=37

Look also specifically at these:

http://www.lcg.org/sock-faq/detail.php3?id=40

http://www.lcg.org/sock-faq/detail.php3?id=44

http://www.lcg.org/sock-faq/detail.php3?id=235

The last two links deal specifically with SO_RESUSEADDR. Setting this may eliminate your problem.

...JRF...