Operating System - HP-UX
1834135 Members
2205 Online
110064 Solutions
New Discussion

Re: Application fails to bind to a socket

 
Amith_2
Frequent Advisor

Application fails to bind to a socket

I am running an application which should bind to a port number mentioned in a configuration file.
The program when executed throws a bind error.

I tried the command netstat on that particular port number but didnt throw any output. It ddidnt say whether it is in LISTEN, ESTABLISHED or FIN_WAIT mode.

The port number which i am trying to bind is 9205. I will attach the output of the netstat command.
4 REPLIES 4
Rick Garland
Honored Contributor

Re: Application fails to bind to a socket

Is this a port that is configured to be on? Look in the /etc/services file and find this port number? Also see if something else is already bound to this port. Can use the utility 'lsof' for this task.

Amith_2
Frequent Advisor

Re: Application fails to bind to a socket

I had checked in the /etc/services and this particular port number is not mentioned in it.How will confirm that the port is configured to be on?
rick jones
Honored Contributor

Re: Application fails to bind to a socket

There really isn't any such thing as configuring a port to be on. All ports are always on. I guess you can think of it as being a part of the Always On Infrastructure :)

The file /etc/services is simply a set of mappings from port numbers to more human-friendly service names. It neither enables or disables the use of a given port number. Some applications may be not terribly robustly written and expect to find their service name in the /etc/services file (modulo other name lookups mechanisms being configured) and not have a fall-back.

Presumeably, the code throwing the bind error should be written to provide the reason _why_ - however, in the absense of such proper coding you can try to use the tusc utility to trace the bind() calls and see what actual errno is being set, which will then help trace the reason.
there is no rest for the wicked yet the virtuous have no pillows
Deepak_22
New Member

Re: Application fails to bind to a socket

use command netstat -nl (list listning ports)
you might want to run the application as root to see if its not a priviledge issue.