Bind failure

Hi all,

I am using Perl program to do socket communication. My application has to use port 40001 this is a condition I can't change the port.

The execution of this script always gave an error 'Bind failure port already in use'

netstat execution gives below line:
udp 0 0 .40001 *.

What this line indicates. I think due this port engagement bind fails. To fix this issue I used port reuse option as below before bind but still bind gives the same error:

setsockopt($serv_sock, IPPROTO_UDP, SO_REUSEADDR, pack("l", 1)) || die "setsockopt: $!";

How can I disengage the port binding?
Please help me in this regard...

Thanks...

you cannot bind to a port that is in use. There is a process that has this open. Use lsof -i to find the pid and kill it.

I am using HP-UX B.11.11 .. there is no lsof command.

not sure of an alternative then.

could it be possible that the program your running is already running ?

ps -ef|grep your_process

if so, kill it.

Actually the thing is my program is not running .. from start I am getting this error. So some other unknown process may using this port. How can I detect the process which uses this 40001 port so that I can kill it. Also I rebooted my machine but then also I find 40001 port engaged with some processes.

OR

Is there any best way to remove this port socket entry from TCB [transmission control block]?

Thanks...

install lsof. If you can't then I don't know what to tell you.