cancel
Showing results for 
Search instead for 
Did you mean: 

Number of socket connection

manan.dave
Occasional Contributor

Number of socket connection

Hi All,
I am using normal socket program in c in HP-UX.I want to know at a time how many client are connected to socket. Is there any command using which i can check how many user are connected to socket ?
Thanks in advance.
7 REPLIES
Steven E. Protter
Exalted Contributor

Re: Number of socket connection

Shalom,

Funny, I just read this in a performance book for HP-UX last night.

netstat -aAn

The man page for netstat will allow you to refine this output.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mel Burslan
Honored Contributor

Re: Number of socket connection

netstat -aAn will not work as -A is not an option in the list of switches for netstat. But you can do

netstat -an > /tmp/mytempfile

then edit this /tmp/mytempfile and look for a pattern saying "Active UNIX domain sockets". After this line, it is all sockets. It is upto you to determine what is connecting to where and then count them.

HTH
________________________________
UNIX because I majored in cryptology...
rick jones
Honored Contributor

Re: Number of socket connection

For a TCP socket, there is by defintion only one client "connected" to a socket. There can, of course be many clients connected to a service residing at a (well) known port number.

For UDP it gets a bit less clear.
there is no rest for the wicked yet the virtuous have no pillows
Prashanth Waugh
Esteemed Contributor

Re: Number of socket connection

Hi Steven,

I checked this command on 11.11 and 11.31 #netstat -aAn. its not giving any out put.also in ma pages i m not able to find A

Regards
Prashant
For success, attitude is equally as important as ability
Turgay Cavdar
Honored Contributor

Re: Number of socket connection

Lsof may be useful for you:

lsof -i@ip_address:port_number
lsof -i@192.168.30.80:1521
Laurent Menase
Honored Contributor

Re: Number of socket connection

Do you mean programatically?
or with a command
if you are looking for a command:
myport is your port num.
nestat -an | grep -v LISTEN |grep \.$myport | wc -l

if you can have loopback connection then
netstat -an| grep '\.23 '| grep -v -E '\.23( )*[A-Z]'\|LISTEN |wc -l

RajuD
Frequent Advisor

Re: Number of socket connection

Hi manan.dave,

Could you post the program.


regards
Rajesh Kumar
“Education is our passport to the future, for tomorrow belongs to those who prepare for it today.”