Operating System - HP-UX
1837324 Members
3416 Online
110116 Solutions
New Discussion

Re: Number of free sockets

 
Sylvain CROUET
Respected Contributor

Number of free sockets

Hi!

How can I determine the number of free available sockets for HP-UX and SunOS systems?
8 REPLIES 8
BONNAFOUS Jean Marc
Trusted Contributor

Re: Number of free sockets

Hi,

Use netstat -a to show status of sockets

See also thread: http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=198427

Rgds

JMB
Si vous ne faites jamais de bétises, c'est que vous ne faites rien de difficile. Et ça c'est une grosse bétise.
Sylvain CROUET
Respected Contributor

Re: Number of free sockets

Well, the question is now: how can I determine the total number of sockets available?
Govind_3
Regular Advisor

Re: Number of free sockets

The beauty of UNIX is that even a socket is a file :) so the answer for your question is, "df -i" which shows the number of free inodes. The number of free inodes at any instant is equal to number of files (what ever kind, ex. directory, character special file, block special file, sockets and plain file) that can be created.
-Cheers
Govind
A. Clay Stephenson
Acclaimed Contributor

Re: Number of free sockets

The number of inodes in a filesystem has nothing to do with this. The socket() system call can fail with resource limits for essentially 3 reasons: 1) ENFILE - the global file table is full. 2) EMFILE - the per process file descriptor limit has been reached 3) ENOBUFS - no memory available for the request -- very rare.

In almost all cases, socket() fails for 1) or 2) so check these kernel limits first.
If you are seeing problems with sockets, it is very important to capture errno. A good programmer will set errno as the program exit code so that ${?} will be set to errno. Errno then equals ENFILE, for example.
If it ain't broke, I can fix that.
Govind_3
Regular Advisor

Re: Number of free sockets

Clay is correct to an extent! Ok let me say my answer was as general as your question Sylvain :) Considering we are not talking about just one process opening all the sockets :) and provided we have ENUF memory and provided you have ENUF diskspace, the answer to your question is "df -i". If its the one process thats openining the sockets then the limit is imposed by the keenelParams stated by Clay.
-Cheers
Govind
Govind_3
Regular Advisor

Re: Number of free sockets

Clay is correct to an extent! Ok let me say my answer was as general as your question Sylvain :) Considering we are not talking about just one process opening all the sockets :) and provided we have ENUF memory and provided you have ENUF diskspace, the answer to your question is "df -i". If its the one process thats openining the sockets then the limit is imposed by the keenelParams stated by Clay. I think I am pretty sure a inode is assigned for every socket used.

-Cheers
Govind
Govind_3
Regular Advisor

Re: Number of free sockets

Clay is correct to an extent! Ok let me say my answer was as general as your question Sylvain :) Considering we are not talking about just one process opening all the sockets :) and provided we have ENUF memory and provided you have ENUF diskspace, the answer to your question is "df -i". If its the one process thats openining the sockets then the limit is imposed by the keenelParams stated by Clay. I think I am pretty sure a inode is assigned for every socket used.
Clay pls correct me if I am wrong!

-Cheers
Govind
Govind_3
Regular Advisor

Re: Number of free sockets

Clay is correct to an extent! Ok let me say my answer was as general as your question Sylvain :) Considering we are not talking about just one process opening all the sockets :) and provided we have ENUF memory and provided you have ENUF diskspace, the answer to your question is "df -i". If its the one process thats openining the sockets then the limit is imposed by the keenelParams stated by Clay. I think I am pretty sure a inode is assigned for every socket used.
Clay pls correct me if I am wrong!

-Cheers
Govind